@@ -85,9 +85,13 @@ features you can refer to the [Cartography](topic_cartography.md) topic page.
8585For example, let's add a legend, barscale, and shaded relief to the map:
8686
8787``` python
88+ from grass.tools import Tools
89+
90+ # Create an object to access tools
91+ tools = Tools()
8892
8993# Compute shaded relief
90- gs.run_command( " r.relief " , input = " elevation" , output = " relief" )
94+ tools.r_relief( input = " elevation" , output = " relief" )
9195
9296# Create a new map
9397m = gj.Map()
@@ -176,10 +180,10 @@ maps and play a continuous loop.
176180# Create a series of relief maps with different angles
177181directions = [0 , 90 , 180 , 270 ]
178182for azimuth in directions:
179- gs.run_command( " r.relief " ,
180- input = " elevation" ,
181- output = f " relief_ { azimuth} " ,
182- azimuth = azimuth)
183+ tools.r_relief(
184+ input = " elevation" ,
185+ output = f " relief_ { azimuth} " ,
186+ azimuth = azimuth)
183187m = gj.SeriesMap()
184188m.add_rasters(f " relief_ { azimuth} " for azimuth in directions)
185189m.d_vect(map = " roads" )
@@ -199,30 +203,30 @@ series map of overland water flow:
199203
200204``` python
201205# Zoom in to the study area
202- gs.run_command( " g.region " , n = 226040 , s = 223780 , e = 639170 , w = 636190 )
206+ tools.g_region( n = 226040 , s = 223780 , e = 639170 , w = 636190 )
203207# Compute topography dx and dy derivatives
204- gs.run_command(" r.slope.aspect" ,
205- elevation = " elevation" ,
206- dx = " dx" ,
207- dy = " dy" )
208+ tools.r_slope_aspect(elevation = " elevation" , dx = " dx" , dy = " dy" )
208209# Compute overland flow
209- gs.run_command( " r.sim.water " ,
210- flags = " t" ,
211- elevation = " elevation" ,
212- dx = " dx" ,
213- dy = " dy" ,
214- depth = " depth" ,
215- niterations = 30 )
210+ tools.r_sim_water(
211+ flags = " t" ,
212+ elevation = " elevation" ,
213+ dx = " dx" ,
214+ dy = " dy" ,
215+ depth = " depth" ,
216+ niterations = 30 )
216217
217218# Create a time series
218- gs.run_command( " t.create " ,
219- output = " depth" ,
220- temporaltype = " relative" ,
221- title = " Overland flow depth" ,
222- description = " Overland flow depth" )
219+ tools.t_create(
220+ output = " depth" ,
221+ temporaltype = " relative" ,
222+ title = " Overland flow depth" ,
223+ description = " Overland flow depth" )
223224# Register the time series
224- maps = gs.list_strings(type = " raster" , pattern = " depth*" )
225- gs.run_command(" t.register" , input = " depth" , maps = maps)
225+ maps = [
226+ item[" fullname" ]
227+ for item in tools.g_list(type = " raster" , pattern = " depth*" , format = " json" )
228+ ]
229+ tools.t_register(input = " depth" , maps = maps)
226230
227231# Create a time series map
228232flow_map = gj.TimeSeriesMap()
@@ -253,6 +257,10 @@ For complete documentation on the `grass.jupyter` package, see the
253257[ grass.jupyter] ( https://grass.osgeo.org/grass-stable/manuals/libpython/grass.jupyter.html )
254258library documentation page.
255259
260+ For complete documentation on the ` grass.tools ` package, see the
261+ [ grass.tools] ( https://grass.osgeo.org/grass-stable/manuals/libpython/grass.tools.html )
262+ library documentation page.
263+
256264For complete documentation on the ` grass.script ` package, see the
257265[ grass.script] ( https://grass.osgeo.org/grass-stable/manuals/libpython/script_intro.html )
258266library documentation page.
0 commit comments