I'm using Jupyter Notebooks in ArcGIS Pro and I would like to convert multiple .laz files into .las files by using the opensource toolbox 'lastools' and its function 'laszip'. For this I would like to iterate through all files within my working directory by using a for-loop.
This is my code so far:
arcpy.env.workspace = r"C:\user\lidar\laz" # Set the workspace
arcpy.ImportToolbox(r"C:\Users\user1\Desktop\LAStools\LAStools\ArcGIS_toolbox\LAStools.tbx.tbx") # Import lastools
for file in arcpy.ListFiles("*.laz"):
outfile = arcpy.Describe(file).baseName + '_las' # Take original file name and add '_las'
arcpy..laszip(input_file=file,
only_report_size=False, also_compress_decompress_waveforms=False,
output_format= "las",
output_file= r"C:\user\lidar\las\{}".format(outfile), # Define Output directory and and 'outfile' for file name
output_directory= r"C:\user\lidar\las",
output_appendix="", additional_command-line_parameters="", verbose=True)
Unfortunately I'm getting this error message:
---------------------------------------------------------------------------
SyntaxError Traceback (most recent call last)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ast.py, in parse:
Line 35: return compile(source, filename, mode, PyCF_ONLY_AST)
SyntaxError: invalid syntax (<string>, line 7)
---------------------------------------------------------------------------
How do I use the lastools toolbox in ArcPy?
for
loop on the workspace string is completely wrong. It's going to iterate the characters of the string['C',':','\\',...]
.arcpy..laszip
is invalid syntax, it would typically bearcpy.toolboxalias.toolname()
arcpy.LAStools.laszip
but it also doesn't work. I also got the code examples by executing the function manually and by copying the python code (send to python), so this was proposed by ArcGIS itself.# Define Output directory and and 'outfile' for file name
) within the function?