Execute las2txt.exe in existing Python script

553 views
Skip to first unread message

Colin Werle

unread,
May 4, 2018, 3:49:30 PM5/4/18
to LAStools - efficient tools for LiDAR processing
Hello, 

I am relatively new to Python scripting, and I would like to add the las2txt (using the parameters of [-i, -sep space,  -o, -parse xyzRBGi, -scale_rgb_down]) once I have finished colorizing las using ArcGIS.

Are there any suggestions for implementing this las2txt tool into my script? 

Thanks!

Colin
las2txtQuestion.PNG

David Friedrich

unread,
May 4, 2018, 4:25:08 PM5/4/18
to LAStools - efficient tools for LiDAR processing
Hi Colin,

the first option would be to go to your LAStoolsArcGIS_toolbox\scripts folder and take a look at the las2text.py.

At the beginning it looks complicated, but it isn't. 
I won't explain all but i will try to give you an idea.

# this defines the LAStoos\bin\las2txt.exe path and writes it to an array
lastools_path = lastools_path + "\\bin"
las2txt_path = lastools_path+"\\las2txt.exe"
command = ['"'+las2txt_path+'"']

# add input LiDAR
command.append("-i")
command.append('"'c:\INPUTFOLDER'"')

# add parameters
command.append("MYPARAMETER")

and so on ...

#finally run las2txt
process = subprocess.Popen(command)


Cheers,
David

------ Originalnachricht ------
Von: "Colin Werle" <werle...@gmail.com>
An: "LAStools - efficient tools for LiDAR processing" <last...@googlegroups.com>
Gesendet: 04.05.2018 16:41:50
Betreff: [LAStools] Execute las2txt.exe in existing Python script

Colin Werle

unread,
May 6, 2018, 4:10:22 PM5/6/18
to LAStools - efficient tools for LiDAR processing
David, 

Thank you for your informative response!

I've used a similar route to your response by running:
subprocess.call("%s -i %s -o %s -parse xyzRBGi -scale_rgb_down" %(las2txtTool,inputLas,outTxt), shell=True)

This route provided the proper output for me, but is there an advantage to using subprocess.Popen() instead?

I appreciate your help!

Colin

David Friedrich

unread,
May 6, 2018, 8:55:40 PM5/6/18
to last...@googlegroups.com
Colin,

subprocess.call is basically:
Popen(*args, **kwargs).wait()

subprocess.popen is more versatile. it gives your more options to interact with the process you are going to start.
i think in your case it makes no difference, you just want to call las2txt and wait without the need to interact based on the output of las2txt.

David

------ Originalnachricht ------
Von: "Colin Werle" <werle...@gmail.com>
An: "LAStools - efficient tools for LiDAR processing" <last...@googlegroups.com>
Gesendet: 06.05.2018 16:41:04
Betreff: Re: [LAStools] Execute las2txt.exe in existing Python script
Reply all
Reply to author
Forward
0 new messages