Skip to content

Instantly share code, notes, and snippets.

@glw
Last active January 24, 2019 21:01
Show Gist options
  • Save glw/bbc95ab13aaa9323649d627f4c220385 to your computer and use it in GitHub Desktop.
Save glw/bbc95ab13aaa9323649d627f4c220385 to your computer and use it in GitHub Desktop.
Pdal Pipeline Cheatsheet

Run PDAL on docker

docker run -it --rm -v $(pwd):/data pdal/pdal pdal pipeline /path/to/json/file/simple_crop.json

Simple_crop.json - using WKT point location and a distance of 50ft

{
  "pipeline":[
    "path/to/original/las/file/lidar.las",
    {
      "type":"filters.crop",
      "point": "Point (1136725.47257809434086084 1987231.01693190541118383)",
      "distance":"50"
    },
    {
      "type":"writers.las",
      "filename":"/path/to/cropped/las/file/cropped_lidar.las"
    }
  ]
}

Simple_reproject.json

{
  "pipeline":[
    "/path/to/lidar.las",
    {
      "type":"filters.reprojection",
      "in_srs":"EPSG:6455",
      "out_srs":"EPSG:4326+6360"
    },
    {
      "type":"writers.text",
      "filename":"path/to/new/reprojected_lidar.csv"
    }
  ]
}

Crop multiple LAS files

{
"pipeline": [
    {
      "filename": "/data/las/10509775.las",
      "tag": "tag_10509775"
    },
    {
      "filename": "/data/las/10259775.las",
      "tag": "tag_10259775"
    },
    {
      "filename": "/data/las/10259750.las",
      "tag": "tag_10259750"
    },
    {
      "filename": "/data/las/10509750.las",
      "tag": "tag_10509750"
    },
    {
      "type": "filters.crop",
      "point": "POINT(1104970.32399 1977682.27218)", 
      "distance":"492",
      "inputs":[
        "tag_10509775",
        "tag_10259775",
        "tag_10259750",
        "tag_10509750"
        ],
      "tag": "clipped_o"
    },
    {
      "type": "writers.las",
      "filename": "/data/las/cropped/clip_o.las"
    }
  ]
}

Crop several LAS with several points and merge results

{
"pipeline": [
    {
      "filename": "/data/las/10509775.las",
      "tag": "tag_10509775"
    },
    {
      "filename": "/data/las/10259775.las",
      "tag": "tag_10259775"
    },
    {
      "filename": "/data/las/10259750.las",
      "tag": "tag_10259750"
    },
    {
      "type": "filters.crop",
      "point": "POINT(1091931.78695 1831913.54880)", 
      "distance":"492",
      "inputs":[
        "tag_105097750"
      ],
      "tag": "clipped_a"
    },
    {
      "type": "filters.crop",
      "point": "POINT(1108768.71304 1829578.57199)", 
      "distance":"492",
      "inputs":[
        "tag_10259775",
        "tag_105097750"
        ],
      "tag": "clipped_b"
    },
    {
      "type": "filters.crop",
      "point": "POINT(1136723.82376 1987234.21768)", 
      "distance":"492",
      "inputs":[
        "tag_105097750",
        "tag_10259750"
      ],
      "tag": "clipped_c"
    },
    {
      "type": "filters.merge",
      "inputs": [
        "clipped_a",
        "clipped_b",
        "clipped_c"
      ],
     "tag": "merged"
    },
    {
      "type": "writers.las",
      "filename": "/data/las/cropped/merge-clipped.las"
    }
  ]
}

Generic Pipeline - Accepts any LAS input and output

{
  "pipeline":[
    "input.las",
    {
      "type":"filters.assign",
      "assignment":"Classification[:]=0"
    },
    {
      "type":"filters.smrf"
    },
    {
      "type":"filters.hag"
    },
    {
      "type":"filters.ferry",
      "dimensions":"HeightAboveGround=Z"
  },
    "output.las"
  ]
}

Run with

docker run -it --rm -v $(pwd):/data pdal/pdal pdal pipeline --readers.las.filename=/data/las/cropped/mylasfile.las --writers.las.filename=/data/las/cropped/newlasfile.las /data/generic_pipeline.json

or in a loop

for file in las/cropped/*.las
do 
BASE=`basename $file .las`
OLDFILE=${BASE}.las
NEWFILE=${BASE}_hag.las
docker run -it --rm -v $(pwd):/data pdal/pdal pdal pipeline --readers.las.filename=/data/las/cropped/$OLDFILE --writers.las.filename=/data/las/cropped/$NEWFILE /data/generic_pipeline.json
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment