Convert a txt file to a las file to view it in Lasedit

1,002 views
Skip to first unread message

matt...@gmail.com

unread,
Jul 4, 2015, 9:15:36 AM7/4/15
to last...@googlegroups.com

 

G’day Lastools forum

 

I’ve just got stuck into my honors project after a sizable absence and I’m struggling to get Lastools to work for me.

 

I’ve designed an elaborate algorithm to extract detailed structural data from vegetation. Its output however takes the form of txt files and in order to test and confirm its effectiveness I need to view the data in lasedit.

 

I know it is possible to convert and view a txt file in lasedit using Lastools as I’ve done it before however I’m buggered if I can work out how I did it.

 

I’m attempting to write up a procedure to achieve this however I’m stuck in commander.

 

My test dataset looks something like figure 1, for simplicity sake this txt file and the Lastools folder are both stored in my Documents folder and when opened looks like figure 2.


Figure 1















Figure 2


















At present my procedure is as follows;

  1. Launch ‘Command Prompt’
    • Select ‘Start’ in the lower left hand corner of Windows
    • Within the ‘Start’ menu find the option ‘Run’
    • Type ‘cmd’ into the ‘Run’ text box and hit ‘Enter’. A black terminal window should appear containing the text “C:\>”.
  2. Navigate to the directory in which the subject txt files are stored. Type ‘cd’ into ‘Command Prompt’ followed by a space and the name of the folder within the directory containing the subject txt files (to access the folder ‘Honours Project’ within the folder ‘Documents’, for example, type “C:\Users\Matt\Documents> Honours Project” then hit enter).
  3. Next enter the code:
txt2las -i lidar.txt.gz -o lidar.las -parse xyz


So that the entire combined code reads;

C:\Users\Matt\Documents> txt2las -i lidar.txt.gz -o lidar.las -parse xyz

 

When I hit ‘Enter’ however, I am returned the error in figure 3, reading “‘txt2las’ is not recognized as an internal or external command, operable program or batch file”.

 

Figure 3.






Nicolas Cadieux

unread,
Jul 4, 2015, 12:27:18 PM7/4/15
to last...@googlegroups.com

Hi,

Windows does not know where lastools is found on your computer. This is normal for programs that don't have a windows install launcher.

You have three options.

1: use the txt2las graphical interface (GUI) by clicking on txt2las.exe found in the lastools folder.

2: Go to the txt2las.exe folder (for example c:\lastools\bin)
And do the command from there. This time you will need to give the files complete path: like

txt2las -i C:\Users\Matt\Documents\lidar.txt.gz -o C:\Users\Matt\Documents\lidar.las -parse xyz

Or best, add the lastools folder to your Windows systems variables so that windows will know in what folder to look for to find lastools. Look that up in the net. It is easy to do.

Nicolas Cadieux M.Sc.
Les Entreprises Archéotec inc. 
8548, rue Saint-Denis Montréal H2P 2H2
Téléphone: 514.381.5112  Fax: 514.381.4995
www.archeotec.ca

Kirk Waters

unread,
Jul 4, 2015, 12:27:38 PM7/4/15
to last...@googlegroups.com
Sounds like txt2las is not in your path environment variable. You either need to set your path to include the folder with lastools (likely something resembling c:\lastools\bin) or give the full path to txt2las when you call it on the command line. Otherwise, the system doesn't know where to find it. Figuring out how to set your path seems like a reasonable task for an honors project.

Albert Godfrind

unread,
Jul 4, 2015, 12:27:43 PM7/4/15
to last...@googlegroups.com
In order to run the command-line LAStools utilities, you must place the bin directory of you LAStools installation in your execution path (i.e. include it in your PATH variable). 

--
Albert Godfrind
+33 6 09 97 27 23
Sent from my iPhone

matt...@gmail.com

unread,
Jul 5, 2015, 4:25:29 AM7/5/15
to last...@googlegroups.com

Cheers for the prompt responses guys


I've attempted to enact your solutions with varying degrees of success, as follows;
 

I tried to add the Lastools folder to my windows system variables, using the following procedure;

 

Windows Vista and Windows 7 users

1.       From the Desktop, right-click the Computer icon and select Properties. If you don't have a Computer icon on your desktop, click the Start button, right-click the Computer option in the Start menu, and select Properties.

2.      Click the Advanced System Settings link in the left column.

3.      In the System Properties window, click on the advanced tab, then click the Environment Variables button near the bottom of that tab.

4.       In the Environment Variables window, highlight the Path variable in the "System variables" section and click the Edit button. Add or modify the path lines with the paths you want the computer to access. Each different directory is separated with a semicolon.

 

The original path looked something like this;

 

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\COMMON~1\ULEADS~1\MPEG;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

 

The new path looked something like this;

 

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\COMMON~1\ULEADS~1\MPEG;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Users\Matt\Documents\LAStools

 

I still get the same result when I run the code, returning me the error in figure 3 of my previous post, reading “‘txt2las’ is not recognized as an internal or external command, operable program or batch file”.

 

I then attempted to run the command from the bin folder by changing directory and then changing the path until I got to the bin folder and then pasting in the line you recommended (txt2las -i C:\Users\Matt\Documents\lidar.txt.gz -o C:\Users\Matt\Documents\lidar.las -parse xyz) however that did not work either, returning ‘ERROR: no input specified’.


 

In the end however I was able to navigate the GUI with relative ease to convert the data which seemed to work quite well initially and the test dataset seemed to look fine when I viewed it in the GUI however when I opened the resultant las file in LASedit I ended up with an unusual result;

 

In Lastools;



In LASedit



I have no idea how this has happened...

Any idea's on what is going on with these?

Martin Isenburg

unread,
Jul 5, 2015, 4:28:26 AM7/5/15
to LAStools - efficient command line tools for LIDAR processing

Wow. This looks beautiful ... (-:

Maybe it is best you upload your data somewhere and send us a link. There is no other way for anyone of us to know what is really going on ...

Martin

matt...@gmail.com

unread,
Jul 7, 2015, 2:08:55 AM7/7/15
to last...@googlegroups.com
G’day Martin
It does look rather interesting, took me quite by surprise when I opened it.

I always seem to have trouble when I try to open the data in LASedit, perhaps I should just stick to the Lastools GUI.

I think I've attached the data to this post, let me know if I have failed.
Thank you again for your help.

Regards
Matt
input txt file.txt.txt
output las file.txt.las

Martin Isenburg

unread,
Jul 13, 2015, 4:41:09 PM7/13/15
to LAStools - efficient command line tools for LIDAR processing
Hello Matt,

seems my usual LiDAR lunatics and forum helpers are all on vacation ... (-:

Your visuals are exactly what you should get. 

D:\LAStools\bin>lasview -i "input txt file.txt.txt" -populate

The input is indeed a funny bunch of points like that (see below). What is that supposed to mean? Were you expecting anything else? The LAS fie contains this content correctly (see even further below). Note that txt2las assumes the x and y coordinates to be longitude / latitude due to their range and therefore uses scale factors of 0.0000001.

Regards,

Martin

PS: Please do not put spaces or points in the middle of your file names.
 
D:\LAStools\bin>more "input txt file.txt.txt"
0,2.5,2.5
0,5,5
0,7.5,7.5
0,10,10
0,12.5,12.5
0,15,15
0,17.5,17.5
0,20,20
0,22.5,22.5
0,25,25
0,27.5,27.5
0,30,30
0,32.5,32.5
0,35,35
0,37.5,37.5
0,40,40
0,42.5,42.5
0,45,45
0,47.5,47.5
0,50,50
0,52.5,52.5
0,55,55
0,57.5,57.5
0,60,60
0,62.5,62.5
0,65,65
0,67.5,67.5
0,70,70
0,72.5,72.5
0,75,75
0,77.5,77.5
0,80,80
0,82.5,82.5
0,85,85
0,87.5,87.5
0,90,90
0,92.5,92.5
0,95,95
0,97.5,97.5
[...]

D:\LAStools\bin>las2txt -i "output las file.txt.las" -stdout | more
0.0000000 2.5000000 2.50
0.0000000 5.0000000 5.00
0.0000000 7.5000000 7.50
0.0000000 10.0000000 10.00
0.0000000 12.5000000 12.50
0.0000000 15.0000000 15.00
0.0000000 17.5000000 17.50
0.0000000 20.0000000 20.00
0.0000000 22.5000000 22.50
0.0000000 25.0000000 25.00
0.0000000 27.5000000 27.50
0.0000000 30.0000000 30.00
0.0000000 32.5000000 32.50
0.0000000 35.0000000 35.00
0.0000000 37.5000000 37.50
0.0000000 40.0000000 40.00
0.0000000 42.5000000 42.50
0.0000000 45.0000000 45.00
0.0000000 47.5000000 47.50
0.0000000 50.0000000 50.00
0.0000000 52.5000000 52.50
0.0000000 55.0000000 55.00
[...]


--

matt...@gmail.com

unread,
Jul 15, 2015, 7:57:51 AM7/15/15
to last...@googlegroups.com

Ah yes I apologize for the unconventional point values I should have explained that the data I’ve attached is an artificial analogue to test my algorithm before I start trying to run it for real field data.

I’ve made this data using simple values without the many decimal places so I can track the calculations in the algorithm more clearly. The values are relative to one and other in a 3D Cartesian plane with coordinates centered around a growth point (at X = 0, Y = 0 and Z = 0) from which my hypothetical tree grows.

Forgive my ignorance but I still can’t seem to understand why your viewer shows the data perfectly but the LASEdit viewer shows such a radically different structure for the exact same data when it is converted to a las file.

Below is a run through of the process and results I am getting, still using the same files as above;

 

I open the txt2las GUI (Lastools>Bin>txt2las).

Select browse, navigate to my lidar.txt file and double click.

I click view and start and subsequently the data is presented exactly as it should be in the ‘just a little LAS and LAZ viewer’ viewer (I’ve hit ‘=’ half a dozen times to make it clearer as seen in figure 1).



Figure 1


The image in the viewer is exactly as I expect the data to look.

I then change the format to ‘las’ of the right hand side of the GUI and hit run and start.

When I double click on the subsequent LASEdit LiDAR file which appears in my folders (figure 2)…

Figure 2


… I’m given the option to select meters or feet, for which I select meters (figure 3)

Figure 3


And the following text box (figure 4), which I simply dismiss by hitting cancel…

Figure 4


This is where I’m getting lost, I don’t understand why the data looks so different and has such a different structure (figure 5) to that in the ‘just a little LAS and LAZ viewer’

 

Figure 5


I do appreciate your help with this as it's completely doing my head in.

I'm certain the solution is deceptively simple however I can't for the life of me see what I'm doing wrong...

Regards
MattRNR
Reply all
Reply to author
Forward
0 new messages