0

I have hundreds of LAZ files that I want to reproject and save in the folder named reproject with the following pipeline. It runs indefinitely but doesn't generate any output file.

json_pipeline = """
[
    {
      "type": "readers.las",
      "filename": "*.laz",
      "spatialreference": "EPSG:4326"
    },
    {
      "type":"filters.reprojection",
      "in_srs": "EPSG:4326",
      "out_srs": "EPSG:3857"
    },
{
  "type": "writers.las",
  "scale_x": "0.0000001",
  "scale_y": "0.0000001",
  "scale_z": "0.001",
  "offset_x": "auto",
  "offset_y": "auto",
  "offset_z": "auto",
  "filename": "reproject/{originalfilename}"
}

] """

import pdal pipeline = pdal.Pipeline(json_pipeline) count = pipeline.execute() arrays = pipeline.arrays metadata = pipeline.metadata log = pipeline.log

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Sher
  • 894
  • 5
  • 18

1 Answers1

0

Don't use Python for this. Use the command line, Luke!

find . -name '*.laz' | xargs -I{} pdal translate \
      --input {} --output reproject/{} \
      --filter reprojection --filters.reprojection.out_srs="EPSG:3857" \
      --writers.las.offset_x="auto" \
      --writers.las.offset_y="auto" \
      --writers.las.offset_z="auto" \
      --writers.las.scale_x=0.01 \
      --writers.las.scale_y=0.01 \
      --writers.las.scale_z=0.001 \
      --writers.las.forward="all"

(Note that all of this should be on a single line or you must use line continuation \ characters.)

The advantages of doing it this way are significant:

  • It is going to run in parallel (use GNU Parallel if you want finer control over that or research how to use xargs)
  • It isn't going to try to load all the data in memory (like your Python scenario above)
  • A little more shell scripting could make it resilient resumable (test if the reproject/{filename} exists and don't do anything if so)

See the PDAL Batch Processing Workshop Example for more details or examples of how to use PowerShell to accomplish the same thing if you are on windows.

Howard Butler
  • 4,013
  • 22
  • 26