From b37a691f96d4a2d8cd4db94e3cea282b2b6597f0 Mon Sep 17 00:00:00 2001 From: hblanken Date: Wed, 3 May 2017 08:33:02 +1000 Subject: [PATCH] Linked contour map generation with ODM DEM model This update links the grass contour code to the ODM project DEM model generated with PDAL, which is located in the project folder /odm_georeferencing/odm_georeferencing_model_dem.tif. It also enables contour and relief maps to be created across regions as it ignores the Location PROJ_INFO with the -o flag. Former-commit-id: ec003c6ffa67e13041f297faff4340eed571783c --- contrib/grass/odm_grass.py | 39 ++++++++------------------------------ 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/contrib/grass/odm_grass.py b/contrib/grass/odm_grass.py index 8cce77fc..78bb6113 100644 --- a/contrib/grass/odm_grass.py +++ b/contrib/grass/odm_grass.py @@ -12,7 +12,6 @@ import grass.script as gscript import grass.script.core import grass.script.setup -vlidarName = 'odm_vlidar' rsurfName = 'odm_rsurf' contourName = 'odm_contour' orthophotoName = 'odm_orthophoto' @@ -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) @@ -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)