Syntax fix, decimation parameter fix, tweaks

Former-commit-id: c41f9121e9
pull/1161/head
Piero Toffanin 2017-06-23 16:15:13 -04:00
rodzic 14e679116e
commit 08f391c599
4 zmienionych plików z 32 dodań i 27 usunięć

Wyświetl plik

@ -345,13 +345,13 @@ def config():
action='store_true', action='store_true',
default=False, default=False,
help='Use this tag to build a DTM (Digital Terrain Model, ground only) using a progressive ' help='Use this tag to build a DTM (Digital Terrain Model, ground only) using a progressive '
'morphological filter in PDAL. Check the --dem* parameters for fine tuning.') 'morphological filter. Check the --dem* parameters for fine tuning.')
parser.add_argument('--dsm', parser.add_argument('--dsm',
action='store_true', action='store_true',
default=False, default=False,
help='Use this tag to build a DSM (Digital Surface Model, ground + objects) using a progressive ' help='Use this tag to build a DSM (Digital Surface Model, ground + objects) using a progressive '
'morphological filter in PDAL. Check the --dem* parameters for fine tuning.') 'morphological filter. Check the --dem* parameters for fine tuning.')
parser.add_argument('--dem-gapfill-steps', parser.add_argument('--dem-gapfill-steps',
metavar='<positive integer>', metavar='<positive integer>',
@ -390,7 +390,7 @@ def config():
action='store_true', action='store_true',
default=False, default=False,
help='Use this tag use the approximate progressive ' help='Use this tag use the approximate progressive '
'morphological filter in PDAL, which computes DEMs faster ' 'morphological filter, which computes DEMs faster '
'but is not as accurate.') 'but is not as accurate.')
parser.add_argument('--dem-decimation', parser.add_argument('--dem-decimation',
@ -398,19 +398,18 @@ def config():
default=1, default=1,
type=int, type=int,
help='Decimate the points before generating the DEM. 1 is no decimation (full quality). ' help='Decimate the points before generating the DEM. 1 is no decimation (full quality). '
'100 decimates ~99% of the points. Useful for speeding up ' '100 decimates ~99%% of the points. Useful for speeding up '
'generation.\nDefault=%(default)s') 'generation.\nDefault=%(default)s')
parser.add_argument('--dem-terrain-type', parser.add_argument('--dem-terrain-type',
metavar='<string>', metavar='<string>',
type=str.lower, # make case insensitive
choices=['FlatNonForest', 'FlatForest', 'ComplexNonForest', 'ComplexForest'], choices=['FlatNonForest', 'FlatForest', 'ComplexNonForest', 'ComplexForest'],
default='ComplexForest', default='ComplexForest',
help='Specifies the type of terrain. This mainly helps reduce processing time. ' help='One of: %(choices)s. Specifies the type of terrain. This mainly helps reduce processing time. '
'FlatNonForest: Relatively flat region with little to no vegetation (slope 1, cell size 3)' '\nFlatNonForest: Relatively flat region with little to no vegetation'
'FlatForest: Relatively flat region that is forested (slope 1, cell size 2)' '\nFlatForest: Relatively flat region that is forested'
'ComplexNonForest: Varied terrain with little to no vegetation (slope 5, cell size 2)' '\nComplexNonForest: Varied terrain with little to no vegetation'
'ComplexForest: Varied terrain that is forested (slope 10, cell size 2)' '\nComplexForest: Varied terrain that is forested'
'\nDefault=%(default)s') '\nDefault=%(default)s')
parser.add_argument('--orthophoto-resolution', parser.add_argument('--orthophoto-resolution',

Wyświetl plik

@ -436,5 +436,5 @@ class ODM_Tree(object):
self.odm_orthophoto_tif_log = io.join_paths(self.odm_orthophoto, 'gdal_translate_log.txt') self.odm_orthophoto_tif_log = io.join_paths(self.odm_orthophoto, 'gdal_translate_log.txt')
self.odm_orthophoto_gdaladdo_log = io.join_paths(self.odm_orthophoto, 'gdaladdo_log.txt') self.odm_orthophoto_gdaladdo_log = io.join_paths(self.odm_orthophoto, 'gdaladdo_log.txt')
def path(self, **args): def path(self, *args):
return io.join_paths(self.root_path, **args) return io.join_paths(self.root_path, *args)

Wyświetl plik

@ -155,7 +155,8 @@ class ODMApp(ecto.BlackBox):
self.texturing['reconstruction'] >> self.georeferencing['reconstruction']] self.texturing['reconstruction'] >> self.georeferencing['reconstruction']]
# create odm dem # create odm dem
connections += [self.args[:] >> self.dem['args'], connections += [self.tree[:] >> self.dem['tree'],
self.args[:] >> self.dem['args'],
self.georeferencing['reconstruction'] >> self.dem['reconstruction']] self.georeferencing['reconstruction'] >> self.dem['reconstruction']]
# create odm orthophoto # create odm orthophoto

Wyświetl plik

@ -1,4 +1,4 @@
import ecto, os, math import ecto, os
from opendm import io from opendm import io
from opendm import log from opendm import log
@ -7,11 +7,12 @@ from opendm import context
from opendm import types from opendm import types
class ODMDemCell(ecto.Cell): class ODMDEMCell(ecto.Cell):
def declare_params(self, params): def declare_params(self, params):
params.declare("verbose", 'print additional messages to console', False) params.declare("verbose", 'print additional messages to console', False)
def declare_io(self, params, inputs, outputs): def declare_io(self, params, inputs, outputs):
inputs.declare("tree", "Struct with paths", [])
inputs.declare("args", "The application arguments.", {}) inputs.declare("args", "The application arguments.", {})
inputs.declare("reconstruction", "list of ODMReconstructions", []) inputs.declare("reconstruction", "list of ODMReconstructions", [])
@ -23,22 +24,23 @@ class ODMDemCell(ecto.Cell):
# get inputs # get inputs
args = self.inputs.args args = self.inputs.args
las_model_exists = io.file_exists(tree.odm_georeferencing_model_las) tree = self.inputs.tree
las_model_found = io.file_exists(tree.odm_georeferencing_model_las)
# Just to make sure # Just to make sure
l2d_module_installed = True l2d_module_installed = True
try: try:
system.run('l2d_classify --help') system.run('l2d_classify --help > /dev/null')
except: except:
log.ODM_WARNING('lidar2dems is not installed properly') log.ODM_WARNING('lidar2dems is not installed properly')
l2d_module_installed = False l2d_module_installed = False
log.ODM_INFO('Create DSM: ' + str(args.dsm)) log.ODM_INFO('Create DSM: ' + str(args.dsm))
log.ODM_INFO('Create DTM: ' + str(args.dtm)) log.ODM_INFO('Create DTM: ' + str(args.dtm))
log.ODM_INFO('{0} exists: {1}'.format(tree.odm_georeferencing_model_las, str(las_model_exists))) log.ODM_INFO('DEM input file {0} found: {1}'.format(tree.odm_georeferencing_model_las, str(las_model_found)))
# Do we need to process anything here? # Do we need to process anything here?
if (args.dsm or args.dtm) and las_model_exists and l2d_module_installed: if (args.dsm or args.dtm) and las_model_found and l2d_module_installed:
# define paths and create working directories # define paths and create working directories
odm_dem_root = tree.path('odm_dem') odm_dem_root = tree.path('odm_dem')
@ -70,17 +72,20 @@ class ODMDemCell(ecto.Cell):
'verbose': '-v' if self.params.verbose else '', 'verbose': '-v' if self.params.verbose else '',
'slope': terrain_params[0], 'slope': terrain_params[0],
'cellsize': terrain_params[1], 'cellsize': terrain_params[1],
'outdir': odm_dem_root, 'outdir': odm_dem_root
'approximate': '-a' if args.dem_approximate else '',
'decimation': args.dem_decimation,
} }
l2d_params = '--slope {slope} --cellsize {cellsize} ' \ l2d_params = '--slope {slope} --cellsize {cellsize} ' \
'{verbose} {approximate} --decimation {decimation} ' \ '{verbose} ' \
'-o ' \ '-o ' \
'--outdir {outdir}'.format(**kwargs) '--outdir {outdir}'.format(**kwargs)
system.run('l2d_classify {0} {1}'.format(l2d_params, tree.odm_georeferencing)) approximate = '--approximate' if args.dem_approximate else ''
system.run('l2d_classify {0} --decimation {1} '
'{2} {3}'.format(
l2d_params, args.dem_decimation,
approximate, tree.odm_georeferencing))
products = [] products = []
if args.dsm: products.append('dsm') if args.dsm: products.append('dsm')
@ -88,7 +93,7 @@ class ODMDemCell(ecto.Cell):
radius_steps = [args.dem_resolution] radius_steps = [args.dem_resolution]
for _ in range(args.dem_gapfill_steps - 1): for _ in range(args.dem_gapfill_steps - 1):
radius_steps.append(radius_steps[-1] * math.sqrt(2)) radius_steps.append(radius_steps[-1] * 3) # 3 is arbitrary, maybe there's a better value?
for product in products: for product in products:
demargs = { demargs = {
@ -98,8 +103,8 @@ class ODMDemCell(ecto.Cell):
'maxsd': args.dem_maxsd, 'maxsd': args.dem_maxsd,
'maxangle': args.dem_maxangle, 'maxangle': args.dem_maxangle,
'resolution': args.dem_resolution, 'resolution': args.dem_resolution,
'radius_steps': ' '.join(map(str, radius_steps)) 'radius_steps': ' '.join(map(str, radius_steps)),
'gapfill': '--gapfill' if len(args.dem_gapfill_steps) > 0 else '' 'gapfill': '--gapfill' if args.dem_gapfill_steps > 0 else ''
} }
system.run('l2d_dems {product} {indir} {l2d_params} ' system.run('l2d_dems {product} {indir} {l2d_params} '