Printing file metadata¶
This exercise uses PDAL to print metadata information. Issue the following command in your OSGeo4W Shell.
pdal info c:/Users/hobu/PDAL/exercises/info/interesting.las --metadata
PDAL metadata is returned a in a tree structure corresponding to processing pipeline that produced it.
Use the JSON processing capabilities of your favorite processing software to selectively access and manipulate values.
Structured Metadata Output¶
Many command-line utilities output their data in a human-readable custom format. The downsides to this approach are significant. PDAL was designed to be used in the context of other software tools driving it. For example, it is quite common for PDAL to be used in data validation scenarios. Other programs might need to inspect information in PDAL’s output and then act based on the values. A human-readable format would mean that downstream program would need to write a parser to consume PDAL’s special format.
JSON provides a nice balance between human- and machine- readable, but
even then it can be quite hard to find what you’re looking for, especially
if the output is long.
pdal command output used in conjunction with a
JSON parsing tool like
jq provide a powerful inspection combination.
For example, we might only care about the
flag for this particular file. Our simple
pdal info --metadata command
gives us that, but it also gives us a bunch of other stuff we don’t need
at the moment either. Let’s focus on extracting what we want using the
pdal info c:/Users/hobu/PDAL/exercises/info/interesting.las --metadata ^ | jq ".metadata.compressed, .metadata.system_id"
- PDAL uses JSON as the exchange format when printing information from info. JSON provides human and machine-readable text data.
- The PDAL metadata document contains background and information about specific metadata entries and what they mean.
- Metadata available for a given file depends on the stage that produces the data. Readers produce same-named values where possible, but it is common that variables are different. Filters and even writers can also produce metadata entries.
- Spatial reference system or coordinate system information is a kind of special metadata. Spatial references are come directly from source data or are provided via options in PDAL.