Lidar in XYZ


Today we had a request from someone looking for lidar data in XYZ format and needing some assistance. They noted that they wanted the data in a usable format, which I take some exception to, but we’ll leave that there for the moment. Given this evidence that people are having trouble getting to XYZ, I wrote something up.

LAS/LAZ to XYZ

Let’s start with the methods that will work from the most common forms of lidar mapping data. That’s data in the ASPRS LAS format or the compressed version of it, LAZ. There are several tools freely available and open source that will convert from LAS or LAZ to ASCII XYZ.

LAStools

Within the open part of LAStools is a program called las2txt. The distribution has the Windows compiled version, but the source code is there if you want to compile for Linux or something else. The default behavior is export only the x, y, and z components of the LAS/LAZ file, but you can export more with the -parse option. Or you may want/need to restrict the export to certain classes, such as only ground points. For example, to export x, y, z, and intensity for only the ground class, you could do the following.

las2txt -parse xyzi -keep_class 2 -i input.laz -o output.txt

There are many more options you can use and they are described in the las2txt README file. Note that a number of the tools in LAStools are commercial and require a license for full functionality. Las2txt is not one of them.

PDAL

The point data abstraction library (PDAL) has a lot of building blocks for working with point data in many formats. PDAL can be set up with some pretty complex operations by describing the operation pipeline in JSON format, but we can also do what we need on the command line. For example, the export the x,y,z and only those fields, you could do

pdal translate --writers.text.order="X,Y,Z" --writers.text.keep_unspecified="false" input.las output.txt

There are quite a few option for outputting the text detailed in the writers.text documentation. If we wanted to limit our output to only class 2 (ground in the ASPRS table), we could do that with

pdal translate --writers.text.order="X,Y,Z" --writers.text.keep_unspecified="false" -f range --filters.range.limits="classification[2:2]" input.laz output.txt

The PDAL tutorials also have useful examples for processing an entire directory.

WhiteboxTools

You may also wish to check out WhiteboxTools. There are a lot of tools in the package and they include an las2ascii tool. However, they don’t support LAZ format, so you’ll be limited to LAS and ZLidar. That may not be a problem for most people.

Digital Coast Data Access Viewer

Those general lidar tools are very handy to have and I’d recommend getting at least one of the packages if you’re often working with lidar. However, if you just need to get the data in XYZ and don’t want to deal with downloading software, you might be able to use the Digital Coast Data Access Viewer (DAV). One caveat is that we focus on coastal data, so we might not have the data you’re looking for.

Limitations

Beyond the obvious limitation of whether or not we have the data, there is also a limit on how large a job you can put in the cart. That limit is currently two billion points, which doesn’t get as much area as it used to with today’s high density lidar point clouds. However, the limit is per cart addition, so you can break a dataset up into multiple boxes and add each to the cart. Unfortunately, it can be very hard to make those boxes exactly match without overlap or gap. It’s worth noting that the web Mercator coordinates of the box are in the URL, so you can adjust that to make it work. You may also notice that the default precision on those coordinates is absurd.

The other issue to note is that the XYZ output from the system has a couple more fields than just XYZ. It also includes fields for the intensity, point class, and time stamp. If you need only the xyz values, you’d need to remove those extra fields. This can be as simple as using the cut command in Linux, or requesting the data in LAZ and using one of the tools above, or writing a simple python or perl script.

Finding Data

If you having used the DAV system before, you should check out a previous post for pointers on using it. It’s intended to be intuitive, so I hope you don’t need that. One key point that is often overlooked is the ‘Draw’ tool in the upper left that lets you draw an area of interest box for your search. Make sure you add the data you want to the cart (there is no fee) and click the cart button in the upper right when you’re ready to checkout.

Set Your Options and Submit

Too many people just hit the next button during checkout and miss all the options. For the output you want, you’ll need to change from the defaults. In the example cart below, the main things to pay attention to for XYZ points are circled in red.

Screengrab of checkout page for lidar data. The dropdown selection boxes for output product (points), output format (ASCII X,Y,Z) and the class selection are circled to highlight them for attention.
Example cart checkout showing where to set the output to points and ASCII xyz format. Also note that the default for data classes is ground only, which you may want to change to all.

Once you’ve set the options for each of your cart items, you can proceed to review the selections and then submit the request. You’ll get a confirmation email, an email for each job as it finishes, and a final summary email. The job emails and the summary email will have links to pick up the data.

Conclusion

There are some easy options to convert lidar data to ASCII XYZ format. I’ll note that doing so throws away a lot of information about each point and puts it into a less efficient format. Instead of converting to ASCII, it may be worth investigating how your software could use LAZ or similar. In the short run, I’m sure you just want to get what your software likes to ingest. In the long run, formats that are more compact and don’t require ASCII to binary conversion might be better. I certainly hope nobody considers ASCII to be the only ‘usable’ format.

2 comments

  1. Hi Kirk, I am trying to write a simple tool in Autolisp that will return the DAV URL for a given rectangle in AutoCAD. I already have tools to convert between state plane, lat/lon, UTM and Google tile coordinates. But I can’t figure out the “coordinates” that DAV uses in the URL. The only thing I determined so far is that 1 unit equals about 2.72 feet.

    Like

    • Bob,
      Sorry, I should have put that in there somewhere. The coordinates in the URL are in web mercator meters. The fact that one unit does not equal a bit over 3 feet is just part of the distortion a projection gives you. It’s why our estimates of the number of points are always a bit off.

      Kirk

      Like

Leave a Reply. Comments are moderated.

This site uses Akismet to reduce spam. Learn how your comment data is processed.