Batch convert .las files to .slpk

3586
13
04-20-2021 11:27 PM
ValerieMFoley
New Contributor

I cannot seem to figure out a way to batch convert several LAS files to the SLPK file type. I have tried both creating a model using model builder but the 'Create Point Cloud Scene Layer Package' tool and the 'Iterate Files' iterator, but the tool will not accept the input of the files from the iterator (reference 'Model' images below). I have also tried to create a python script and run it using the notebooks option in ArcGIS Pro and am able to have multiple .las files convert into a single .slpk file but I cannot get the script to output a single .slpk for each .las (reference 'Script_error' image below). Any help would be great, I have exhausted my online resources. 

 

Script of multiple .las to a single .slpk:

import arcpy
import os

from arcpy import env
arcpy.env.overwriteOutput = True

wksp = env.workspace = "C:\LiDARTest"

inpath = "C:\LiDARTest\InFile"
outpath = "C:\LiDARTest\OutFile"

Output_Coordinate_System="PROJCS['NAD_1983_2011_StatePlane_Illinois_East_FIPS_1201_Ft_US',GEOGCS['GCS_NAD_1983_2011',DATUM['D_NAD_1983_2011',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',984250.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-88.33333333333333],PARAMETER['Scale_Factor',0.999975],PARAMETER['Latitude_Of_Origin',36.66666666666666],UNIT['Foot_US',0.3048006096012192]];-17463800 -46132600 3048.00609601219;-100000 3048.00609601219;-100000 10000;3.28083333333333E-03;3.28083333333333E-03;0.001;IsHighPrecision"

arcpy.management.CreatePointCloudSceneLayerPackage(in_dataset=inpath, out_slpk=outpath, out_coor_system=Output_Coordinate_System, transform_method=[], attributes=["INTENSITY", "RGB", "CLASS_CODE", "FLAGS", "RETURNS"], xy_max_error_m=0.01, z_max_error_m=0.01, in_coor_system="", scene_layer_version="2.x")

Script of multiple .las to multiple .slpk:

 

import arcpy
import os

from arcpy import env
arcpy.env.overwriteOutput = True

wksp = env.workspace = "C:\LiDARTest"

rootdir = "C:\LiDARTest\InFile"

name = 0
Output_Coordinate_System="PROJCS['NAD_1983_2011_StatePlane_Illinois_East_FIPS_1201_Ft_US',GEOGCS['GCS_NAD_1983_2011',DATUM['D_NAD_1983_2011',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',984250.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-88.33333333333333],PARAMETER['Scale_Factor',0.999975],PARAMETER['Latitude_Of_Origin',36.66666666666666],UNIT['Foot_US',0.3048006096012192]];-17463800 -46132600 3048.00609601219;-100000 3048.00609601219;-100000 10000;3.28083333333333E-03;3.28083333333333E-03;0.001;IsHighPrecision"

for subdirs, dirs, files in os.walk(rootdir):
     for file in files:
          output_layer = "C:\\LiDARTest\\OutFile\\" + str(name)
          arcpy.management.CreatePointCloudSceneLayerPackage(in_dataset=file, out_slpk=output_layer, out_coor_system=Output_Coordinate_System, transform_method=[], attributes=["INTENSITY", "RGB", "CLASS_CODE", "FLAGS", "RETURNS"], xy_max_error_m=0.01, z_max_error_m=0.01, in_coor_system="", scene_layer_version="2.x")
          name = name+1

*ignore my naming convention have not taken the time to work on that part of the script

0 Kudos
13 Replies
Andrew--Johnson
Esri Regular Contributor

Hi,

 

Can you try if this snippet works for you? Make sure to switch out the coordinate system/transformation etc.

 

import arcpy
import os

path = r"C:\test\lidar"
arcpy.env.workspace = path
arcpy.env.overwriteOutput = True


for root, dirs, files in os.walk(path):
    for name in files:
        if name.endswith(".las"):
            fullpath = os.path.join(root,name)
            print(fullpath)
            slpkName = os.path.splitext(name)[0]
            arcpy.management.CreatePointCloudSceneLayerPackage(fullpath, out_slpk=slpkName, out_coor_system=arcpy.SpatialReference(26913), transform_method="", attributes=["INTENSITY", "RGB", "CLASS_CODE", "FLAGS", "RETURNS"], point_size_m=0, xy_max_error_m=0.01, z_max_error_m=0.01, in_coor_system="", scene_layer_version="2.x")            

 

0 Kudos
ValerieMFoley
New Contributor

It still isn't running successfully, I get the attached error message

0 Kudos
Andrew--Johnson
Esri Regular Contributor

Hi,

It looks like there's a syntax error somewhere in the script. Can you do a couple things

 

1. If you haven't already manually ran this through the tool please do that just to ensure the slpk is successfully created from the las file.

2. Paste your full script again with the updates I sent so I can see where this syntax error might be.

 

thanks!

Andrew

0 Kudos
ValerieMFoley
New Contributor

Ran it through manually and it worked. Attached is my script file.

0 Kudos
Andrew--Johnson
Esri Regular Contributor

Hi,

Thanks for sending that and I was able to successfully run that on my end with my own set of LAS files. Based on the error "Syntax error invalid JSON geometry representation" there seems to be something specific with python being able to read this specific LAS file. Are you able to share that LAS file with me too?

thanks,

Andrew

0 Kudos
ValerieMFoley
New Contributor

I cannot share the LAS file, but when I run it using a single file in the geoprocessing tool is works fine. 

0 Kudos
ValerieMFoley
New Contributor

I have been able to get it to work with another subset of .las files but cannot get it to work with the subset I need. I continue to get the error "

ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Syntax error in JSON geometry representation
Failed to execute (CreatePointCloudSceneLayerPackage)."
0 Kudos
Andrew--Johnson
Esri Regular Contributor

Thanks for testing on another subset. I think that narrows it down more to an issue with the LAS file JSON geometry. Without being able to review the LAS file myself unfortunately I'm not sure what else I can recommend. You may want to try and run the Convert LAS tool with all the LAS options enabled to see if that resolves the issue. Another option is you can right click on the GP tool and select Batch and then batch input to the tool and run it that way.

Andrew--Johnson_0-1619037913016.png

Andrew--Johnson_1-1619038123068.png

 

 

0 Kudos
ValerieMFoley
New Contributor

Would it be possible to schedule a screen share technical appointment? The batch convert option is also not reading the files correctly. 

0 Kudos