[GRASS-SVN] r73064 - grass-addons/grass7/raster/r.in.pdal

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 8 18:34:20 PDT 2018


Author: wenzeslaus
Date: 2018-08-08 18:34:19 -0700 (Wed, 08 Aug 2018)
New Revision: 73064

Modified:
   grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py
Log:
r.in.pdal: add using the computational region (GRASS default behavior)

Modified: grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py
===================================================================
--- grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py	2018-08-09 01:12:47 UTC (rev 73063)
+++ grass-addons/grass7/raster/r.in.pdal/r.in.pdal.py	2018-08-09 01:34:19 UTC (rev 73064)
@@ -139,6 +139,12 @@
 #% description: In scan mode, print using shell script style
 #%end
 
+#%flag
+#% key: e
+#% label: Use the extent of the input for the raster extent
+#% description: Set internally computational region extents based on the point cloud
+#%end
+
 import os
 import sys
 import json
@@ -263,6 +269,7 @@
     # flags
     scan = flags['s']
     shell_script_style = flags['g']
+    input_as_extent = flags['e']
 
     # overwrite auf true setzen
     os.environ['GRASS_OVERWRITE'] = '1'
@@ -338,35 +345,36 @@
     elif footprint:
         footprint_to_vectormap(infile, footprint)
     else:
-        # get region with pdal
-        footprint_to_vectormap(infile, 'tiles')
+        if input_as_extent or raster_file or raster_reference:
+            # get region with pdal
+            footprint_to_vectormap(infile, 'tiles')
 
-        if raster_file:
-            raster_reference = 'img'
-            grass.run_command('r.external',
-                              input=raster_file,
-                              flags='o',
-                              output=raster_reference
-                              )
-            result = grass.find_file(name=raster_reference, element='raster')
-            if result[u'fullname'] == u'':
-                raster_reference = 'img.1'
-        # first pass: set region to extent of tiles while aligning pixel
-        # geometry to raster_reference
-        grass.run_command('g.region', vector='tiles', flags='p')
-        if raster_reference:
+            if raster_file:
+                raster_reference = 'img'
+                grass.run_command('r.external',
+                                  input=raster_file,
+                                  flags='o',
+                                  output=raster_reference
+                                  )
+                result = grass.find_file(name=raster_reference, element='raster')
+                if result[u'fullname'] == u'':
+                    raster_reference = 'img.1'
+            # first pass: set region to extent of tiles while aligning pixel
+            # geometry to raster_reference
+            grass.run_command('g.region', vector='tiles', flags='p')
+            if raster_reference:
+                grass.run_command('g.region',
+                                  vector='tiles',
+                                  flags='ap',
+                                  align=raster_reference
+                                  )
+            # second pass: change raster resolution to final resolution while best
+            # effort aligning to pixel geometry
             grass.run_command('g.region',
                               vector='tiles',
                               flags='ap',
-                              align=raster_reference
+                              res=resolution
                               )
-        # second pass: change raster resolution to final resolution while best
-        # effort aligning to pixel geometry
-        grass.run_command('g.region',
-                          vector='tiles',
-                          flags='ap',
-                          res=resolution
-                          )
 
         # . pdal pipline laz2json (STDOUT) | r.in.xyz
         bn = os.path.basename(infile)



More information about the grass-commit mailing list