forked from perrygeo/mower
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
23 lines (17 loc) · 688 Bytes
/
Copy pathexample.py
File metadata and controls
23 lines (17 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from mower import GrassSession
DEM = "/home/mperry/projects/shortcreek/dem/dem.img"
with GrassSession(DEM) as gs:
from grass.pygrass.modules.shortcuts import raster
# Import/Link to External GDAL data
raster.external(input=DEM, output="dem")
# Perform calculations
raster.mapcalc(expression="demft=dem*3.28084")
raster.slope_aspect(elevation="demft", slope="slope", aspect="aspect")
# Export from GRASS to GDAL
from grass.pygrass.gis import Mapset
m = Mapset()
for r in m.glist('rast'):
if r == "dem":
# don't save the original
continue
raster.out_gdal(r, format="GTiff", output="/tmp/{}.tif".format(r), overwrite=True)