TransWikia.com

Extracting LAS/LAZ info in a performant way with PDAL?

Geographic Information Systems Asked on February 3, 2021

I can do this:

import json
import subprocess as sp

laz_file = somefile.laz
r = (sp.run(['pdal', 'info', laz_file], stderr=sp.PIPE, stdout=sp.PIPE))
json_info = json.loads(r.stdout.decode())

and parse through the JSON, get the info I need (EPSG code and min/max x/y). It does "work."

However calling this workflow on a laz file, especially when some of mine are over 1 gb, takes significantly longer than a las file. As I am iterating over hundreds of laz files (which change daily and sometimes hourly) and intending the output to be used as a dynamic map tracker for our holdings.

How can I extract the EPSG code and the bounding box in a more performant way?

One Answer

According to the doc of pdal info:

If no options are provided, --stats is assumed.

This means that you need to read the entire point cloud to derive information that you don't actually need. What you are looking for is in the metadata of the file (the header). You don't need to read the payload (the points) at all. Try

pdal info file.las --metadata 

This will return your info (epsg, bbox) virtually instantaneously. You will maybe need a bit more parsing however. The EPSG code is stored is the Variable Length Record (VLR) with a key "LASF_Projection". Should look like that.

"vlr_0":
{
  "data": "AQABAAAABQAABAAAAQABAAAMAAABAIkLBAwAAAEAKSMDEAAAAQApIwAQAAABAGcE",
  "description": "by LAStools of rapidlasso GmbH",
  "record_id": 34735,
  "user_id": "LASF_Projection"
},

The bounding box can be found at the begining

"maxx": 684993.29,
"maxy": 5018007.25,
"maxz": 29.97,
"minor_version": 2,
"minx": 684766.39,
"miny": 5017773.08,
"minz": 0,

Answered by JRR on February 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP