Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links contour map generation with ODM DEM model #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 8 additions & 31 deletions contrib/grass/odm_grass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import grass.script.core
import grass.script.setup

vlidarName = 'odm_vlidar'
rsurfName = 'odm_rsurf'
contourName = 'odm_contour'
orthophotoName = 'odm_orthophoto'
Expand Down Expand Up @@ -65,47 +64,25 @@ def main():
gscript.run_command('g.region', flags='s', n=n, s=s, e=e, w=w, res=0.01,
res3=0.01, overwrite=overwrite)

dem(projectHome)
contour(projectHome)
relief(projectHome)

os.remove(gisrc)


def dem(projectHome):
"""
Creates a DEM in GeoTIFF format.
NB: this is a data raster, not an RGBA raster
and so is normally only readable by GIS and not image software.
"""
print 'Creating DEM'

step = 0.5
gscript.run_command('v.in.lidar', flags='beo',
input=projectHome +
'/odm_georeferencing/odm_georeferenced_model.ply.las',
output=vlidarName, overwrite=overwrite)

gscript.run_command('v.surf.bspline', input=vlidarName,
raster_output=rsurfName,
ew_step=step, ns_step=step, method='bicubic',
memory=4096, overwrite=overwrite)

gscript.run_command('r.out.gdal', flags='cfm', input=rsurfName,
output=projectHome+'/odm_georeferencing/odm_dem.tif',
format='GTiff', type='Float32',
createopt='TILED=yes,COMPRESS=DEFLATE,PREDICTOR=2,' +
'BLOCKXSIZE=512,BLOCKYSIZE=512', nodata=0,
overwrite=overwrite)


def contour(projectHome):
"""
Creates a contour map.
Creates a contour map based on the ODM project DEM model.
"""
print 'Creating contour map'

step = 0.25

gscript.run_command('r.in.gdal', flags='o',
input=projectHome+'/odm_georeferencing/odm_georeferencing_model_dem.tif',
output=rsurfName, memory=2047,
overwrite=overwrite)

gscript.run_command('r.contour', input=rsurfName, output=contourName,
step=step, overwrite=overwrite)

Expand All @@ -122,7 +99,7 @@ def relief(projectHome):
"""
print 'Creating relief map'

gscript.run_command('r.in.gdal', flags='e',
gscript.run_command('r.in.gdal', flags='o',
input=projectHome+'/odm_orthophoto/odm_orthophoto.tif',
output=orthophotoName, memory=2047,
overwrite=overwrite)
Expand Down