Subscribe to this thread
Home - General / All posts - M9 experiments importing point cloud data from las files
danb


1,668 post(s)
#20-Nov-18 23:51

I have recently been experimenting with different ways to bring directories of *.las files into M9.

Building on the methods posted a while back:

http://www.georeference.org/forum/t138755.19#138778

To this end, I have undertaken a crude comparison of 5 different variations on the method which I have been using. A winner has emerged and I have adopted this as my method of choice for now.

Anyway, I thought this may have relevance to others with lidar holdings and there may be other options which can also be tried to see if the performance can be improved still further.

PS I have a Manifold 8 script which I use to build my las file import query for M9 (I haven't delved into M9 scripting yet). I attach this here for modification or improvement or even porting to M9. At the top of the script:

path = The folder containing the las files

outTbl = The name of the output table

intClass = The lidar classification to retain.

Attachments:
Lidar point cloud import methods.mxb
M8 BUILD LAS DATASOURCE INSERT FOR M9.txt


Landsystems Ltd ... Know your land | www.landsystems.co.nz

rk
282 post(s)
#21-Nov-18 09:07

I did similar import from different format and different purpose, so now I have Iropython script for M9 that was easy enought to adapt to your case. I have not tested it at all, so expect some errors.

I use properties of certain table [00_Constants] to define projectwise constants. That way the constants are accessible from scripts and queires alike.

# IronPython

from System import Array

querytemplate = """

INSERT INTO [T4 Result] 

SELECT 

 VectorValue(GeomCoordXYZ([Geom], 0), 0) AS [X], 

 VectorValue(GeomCoordXYZ([Geom], 0), 1) AS [Y], 

 VectorValue(GeomCoordXYZ([Geom], 0), 2) AS [Z], 

 [CLASSIFICATION], 

 [GEOM] 

FROM

 [<LAS>]::[<LAS>] 

WHERE 

 [CLASSIFICATION] = <CLASS>

;

"""

def Main():

 app = Manifold.Application

 db = app.GetDatabaseRoot()

 LASFirstNumberFrom = int(db.GetProperty('00_Constants', 'LASFirstNumberFrom'))

 LASFirstNumberTo = int(db.GetProperty('00_Constants', 'LASFirstNumberTo'))

 LASLastNumberFrom = int(db.GetProperty('00_Constants', 'LASLastNumberFrom'))

 LASLastNumberTo = int(db.GetProperty('00_Constants', 'LASLastNumberTo'))

 LASFileNameBeginsWith = db.GetProperty('00_Constants', 'LASFileNameBeginsWith')

 LASNumberFormat = len(db.GetProperty('00_Constants', 'LASNumberFormat'))

 LASFirstNumber = range(LASFirstNumberFrom, LASFirstNumberTo+1)

 LASLastNumber = range(LASLastNumberFrom, LASLastNumberTo+1)

 class = int(db.GetProperty('00_Constants', 'LASImportClass'))

 ###  If not one range then list all block numbers and uncomment next line

 #LASFirstNumber = [18,20]

 #LASLastNumber = [35,36,38]

 

 

 for f in LASFirstNumber:

  for l in LASLastNumber:

   las = block_prefix + str(f).rjust(LASNumberFormat, '0') + str(l).rjust(LASNumberFormat, '0')

   app.Log("Reading las " + las)

   text = querytemplate.replace("<LAS>", las).replace("<CLASS>", class)

   try:

    cmd = db.RunCompile(text)

   except:

    app.Log(las + " does not exist ")

   else: 

    with db.Run(text) as table:

     with table.SearchAll(Array[str]([ "result" ])) as sequence:

      sequence.Fetch() # fetch the only record

      app.Log(str(sequence.GetValues()[0].Data) + " points (class " + str(class) + ") inserted from " + las)

Attachments:
Lidar_point_cloud_py_import_script.mxb

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.