Skip to content

Instantly share code, notes, and snippets.

@chambbj
Last active November 20, 2017 20:53
Show Gist options
  • Select an option

  • Save chambbj/5ae996a69095212165191358768b2af3 to your computer and use it in GitHub Desktop.

Select an option

Save chambbj/5ae996a69095212165191358768b2af3 to your computer and use it in GitHub Desktop.

Revisions

  1. chambbj revised this gist Nov 20, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions main.md
    Original file line number Diff line number Diff line change
    @@ -34,11 +34,11 @@ We've [briefly discussed](https://github.com/PDAL/PDAL/pull/1693) a new filter t
    },
    {
    "type":"filters.assign",
    assignment":"TempClass![2:2]=0"
    "assignment":"TempClass![2:2]=0"
    },
    {
    "type":"filters.groupby",
    dimension":"TempClass"
    "dimension":"TempClass"
    },
    {
    "type":"writers.las",
  2. chambbj revised this gist Nov 20, 2017. 1 changed file with 12 additions and 12 deletions.
    24 changes: 12 additions & 12 deletions main.md
    Original file line number Diff line number Diff line change
    @@ -4,14 +4,14 @@ Now a brute force solution immediately came to mind. What if we reassigned every

    ```json
    {
    pipeline:[
    "pipeline":[
    {
    type”:”filters.assign,
    assignment”:”Classification![2:2]=0
    "type":"filters.assign",
    "assignment":"Classification![2:2]=0"
    },
    {
    type”:”filters.groupby,
    dimension”:”Classification
    "type":"filters.groupby",
    "dimension":"Classification"
    },
    {
    "type":"writers.las",
    @@ -27,18 +27,18 @@ We've [briefly discussed](https://github.com/PDAL/PDAL/pull/1693) a new filter t

    ```json
    {
    pipeline:[
    "pipeline":[
    {
    type”:”filters.ferry,
    dimensions”:”Classification=TempClass
    "type":"filters.ferry",
    "dimensions":"Classification=TempClass"
    },
    {
    type”:”filters.assign,
    “assignment”:”TempClass![2:2]=0
    "type":"filters.assign",
    “assignment":"TempClass![2:2]=0"
    },
    {
    type”:”filters.groupby,
    “dimension”:”TempClass
    "type":"filters.groupby",
    “dimension":"TempClass"
    },
    {
    "type":"writers.las",
  3. chambbj created this gist Nov 20, 2017.
    51 changes: 51 additions & 0 deletions main.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    We recently had a user inquire about how to split their LAS file by classification, resulting in one file with all ground returns (classification = 2) and another with everything else. While we have the `filters.groupby` filter that can do something very close to this, you'd actually end up with individual files for **every** classification present.

    Now a brute force solution immediately came to mind. What if we reassigned everything but ground to a common value with `filters.assign` and then used `filters.groupby`?

    ```json
    {
    “pipeline”:[
    {
    “type”:”filters.assign”,
    “assignment”:”Classification![2:2]=0”
    },
    {
    “type”:”filters.groupby”,
    “dimension”:”Classification”
    },
    {
    "type":"writers.las",
    "filename":"output_#.las"
    }
    ]
    }
    ```

    The obvious drawback to this approach is that while you have succesfully split your point cloud based on the ground/non-ground criteria, you've now lost all classification information for your non-ground points. No good.

    We've [briefly discussed](https://github.com/PDAL/PDAL/pull/1693) a new filter that would enable splitting on any number of specified DimRanges, which would've been perfect for this situation, but in the meantime, the following pipeline that creates a temporary dimension first using `filters.ferry` is all we need.

    ```json
    {
    “pipeline”:[
    {
    “type”:”filters.ferry”,
    “dimensions”:”Classification=TempClass”
    },
    {
    “type”:”filters.assign”,
    “assignment”:”TempClass![2:2]=0”
    },
    {
    “type”:”filters.groupby”,
    “dimension”:”TempClass”
    },
    {
    "type":"writers.las",
    "filename":"output_#.las"
    }
    ]
    }
    ```

    This is of course nearly identical to the first pipeline, except that we have first copied the classification values to a new, temporary dimension called `TempClass`. All assignment and groupby operations are applied to the temporary dimension, leaving the original classifications in tact!