2

I am using PDAL (through Python) to crop multiple polygons from a point cloud and store them as separate files. For efficiency reasons I would like to define this in a single pipeline. However, using the approach shown below, PDAL only seems to store the data related to the last defined polygon. Is it possible to write multiple files with a single pipeline?

pipeline_definition = {
    'pipeline': [
        {
            'type': 'readers.las',
            'filename': input_file,
            'tag': 'read'
        },
        {
            'type': 'filters.crop',
            'polygon': poly1.wkt,
            'inputs': ['read'],
            'tag': 'poly1'
        },
        {
            'type': 'filters.crop',
            'polygon': poly2.wkt,
            'inputs': ['read'],
            'tag': 'poly2'
        },
        {
            'type': 'writers.las',
            'filename': 'branching_1.las',
            'inputs': ['poly1']
        },
        {
            'type': 'writers.las',
            'filename': 'branching_2.las',
            'inputs': ['poly2']
        }
    ]
}

pipeline = pdal.Pipeline(json.dumps(pipeline_definition))
pipeline.validate()
pipeline.execute()
3

This kind of pipeline isn't supported at the moment, but we do have a ticket discussing how to do so.

There's another way that might be relevant to you. You can use the combination of filters.assign and filters.groupby to grab you polygons from an OGR-readable data source. Presumably you're having to do that to get your WKT anyway, so maybe this will make things simpler for you.

{
  "pipeline":[
    {
        "type":"readers.las",
        "filename":"input.las"
    },
    {
      "type":"filters.overlay",
      "dimension":"Classification",
      "datasource":"attributes.shp",
      "layer":"attributes",
      "column":"CLS"    
    },
    {
      "type":"filters.groupby",
      "dimension":"Classification"
    },
    {
      "type":"writers.las",
      "filename":"#out.las",
      "forward":"all"
    }
  ]
}
  • Thanks for this helpful insight. If I understand correctly, the overlay filter assigns a unique value to each unique value of the column, which are then grouped by the groupby filter. However, the overlay filter doesn't seem to work on the column that I need it to work on (a numeric id). In this case, it only produces two values, where I would have expected several hundreds. On other columns (such as the surface area of a building) it does seem to work as intended. Any idea why this seems to be the case? – jelleve May 10 '18 at 18:43
  • Please file a ticket with a small example if possible. Overlay assigns a value to the polygons CLS value for the requested dimension. It only works in 2D. – Howard Butler May 11 '18 at 2:40
  • The problem seems to be that my building id's are all rather large numbers, whereas the Classification dimension is only capable of handling int8 data. If this is considered unintended behavior (although I doubt it), I'll file a ticket. – jelleve May 11 '18 at 12:27
  • To add to the solution: filters.ferry is particularly useful in conjunction with filters.overlay, as it allows you to create new dimensions. – jelleve May 11 '18 at 14:12
  • Yes, if you have values that can’t fit into a Classification dimension, you will need to make a new on with filters.ferry or insert them in a bigger dimension like Intensity (uint16) – Howard Butler May 12 '18 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.