As part of a geo-indexing script, I'd like to add in support for numerous .laz files we have sitting around on our SAN. The only intent of the handler is to grab the filename/path, the SRS, and the extent of the point cloud file. I do not need to do any processing or analysis on the dots.

So I'm able to do

from laspy.file import File

my_file = File("path/to/file.laz", mode='r')

and it loads the files without error. I can call the File.header property, but have no idea how to "get into" it to extract values or calculate the min/max X/Y.


You should use min and max property of header.

from laspy.file import File

f = File("path/to/file.laz", mode='r')
h = f.header

# h.min: [min_x, min_y, min_z] - h.max: [max_x, max_y, max_z]
extent = [*h.min, *h.max] # extent: [min_x, min_y, min_z, max_x, max_y, max_z]
  • Thanks Kadir; is there a way for me to discern the spatial reference from the header? Or just dump all the header contents as a dict and look through them? I was able to grab the min/max as you showed but it was just line and sample, not coordinate information. – auslander May 22 '20 at 20:49
  • I've just looked at laspy docs. It says "srs is not implemented". So, you should probably dump the header contents or use liblas. – Kadir Şahbaz May 22 '20 at 21:20
  • Great. How do I dump the header contents? That was part of the question alluded to in my original question on how to get into the header to examine all the values. – auslander May 23 '20 at 14:54
  • Please check these posts: gis.stackexchange.com/a/203395/29431 and gis.stackexchange.com/a/80762/29431 – Kadir Şahbaz May 23 '20 at 20:48
  • 1
    Use PDAL to get your SRS info. – Howard Butler May 29 '20 at 1:09

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.