7

I am using the python api of liblas to read/write las files. I would like to get the spatial reference information of the las file using liblas, but have been unable to figure it out.

Can anyone offer some advice on how to go about getting this information?

3

To be honest, I think the easiest way would be to shell out to lasinfo with the --xml argument, and then use ElementTree or some such to pluck out what you need from the XML.

You can reach all this stuff from the Python bindings too, but it's a bit of a mess. In short, open the file, fetch the header, and fetch the srs, and then ask for the wkt of the srs. This all assumes you have libLAS + GeoTIFF + GDAL enabled, and degrades poorly if you don't have all three of those things linked together.

Additionally, if all you want to do is interact with LAS files, laspy is a much better alternative to libLAS at this time. laspy doesn't allow you do anything with the coordinate system stuff in LAS other than to fetch the GeoTIFF bytes out of the file, but it is a full-featured library in every other way. It's pure Python + numpy, easy to deploy, and behaves naturally, unlike libLAS (disclaimer, I'm the libLAS author and I helped bootstrap laspy as an effort to obsolete libLAS).

Hope this helps,

Howard

  • Hello Howard. I've been reading much of your work in my research. I recently implemented liblas as it seemed to do what I wanted. However, it does seem as though less work is being done on it now. I regret to hear about liblas, but maybe it's a good time to go ahead and implement laspy. Thank you Howard. – Barbarossa Dec 17 '13 at 15:41
  • 2
    libLAS is eclipsed by two things -- Martin Isenberg releasing his LASlib efforts as LGPL, and my efforts on PDAL to develop a more generic GDAL-like framework for point cloud data translation and processing. I'm happy to include patches to libLAS, and we might have a release again in the next six months to a year, but I am not actively developing on it. – Howard Butler Dec 17 '13 at 15:53
  • Thanks again. Is it possible to retrieve the projection information out of the GeoTIFF bytes? – Barbarossa Dec 17 '13 at 17:39
  • Could you clarify @Howard Butler? When you say "shell out to lasinfo" do you mean the lasinfo that comes with liblas? Can that be run from bash (but not python)? Would liblas.las.LASSRS_GetProj4 give the CRS? (no luck trying it) Or, could you perhaps reveal the CRS and datum associated with simple.las in the laspy data folder? – J Kelly Nov 6 '14 at 14:50
  • 1
    @HowardButler I am revisiting this question nearly 2 years after asking it, to get your insight. I switched over to laspy shortly after your suggestion to do so, however, I am still trying to find an elegant (hopefully pythonic) way to read/write geotiff keys to LAS headers, specifically vertical coordinate system information. Can you make any suggestions? – Barbarossa Nov 20 '15 at 21:28
-1

I haven't used liblas before. But I was reading the documentation and found that you may need to use las2las for coordinate system description and alteration.

The arguments you may need are:

--a_srs arg or --t_srs arg

lasinfo might also be useful for getting extents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.