[pdal] PDAL Pipeline Extensibility

Kristian Evers kreve at sdfe.dk
Thu Dec 29 13:16:46 PST 2016


Howard,

Recently I have had a need for feeding user data to the programmable filter. I have an application that creates a PDAL pipeline based on the input and various settings determine the output. In some cases I use the programmable filter to do something that is outside the current scope of PDAL. If it were possible to access the pipeline JSON, and the userData section of the pipeline, from the Python function behind the filter I would be able to make more generic filters.
A recent example is that I wanted to create a vertical gridshift filter (similar to what Proj.4 does). I would have liked to pass the grid name to the programmable filter as a PDAL pipeline parameter but that is not possible. Instead I ended up hard coding it. It did the job but wasn't a very satisfying solution. I have since realized that I can in fact use the reprojection filter to do this (via Proj.4). This is just the example that came to mind – I have been in similar situations before but the exact details escape my memory.

The Python function prototype will have to be changed. It is best demonstrated with an example. I have extended the multiply_z function from the filters.programmable doc page with my suggestion:

          import numpy as np

          def multiply_z(ins, outs, pipeline):
              f = pipeline[1]['userData']['z_factor']
              Z = ins['Z']
              Z = Z * f
              outs['Z'] = Z
              return True

Info about the other stages in a pipeline should also be available. For the above case the pipeline dictionary would be constructed with:

        with open(‘pipeline.json’) as json_file:
            pipeline = json.load(json_file)[‘pipeline’]



It is not exactly what you are asking about here but I think it is a nice addition to the "userData" concept that you are introducing. My suggestion can of course be extended to filters.predicate as well.

/Kristian


> -----Oprindelig meddelelse-----
> Fra: pdal [mailto:pdal-bounces at lists.osgeo.org] På vegne af Howard Butler
> Sendt: 29. december 2016 19:45
> Til: pdal
> Emne: Re: [pdal] PDAL Pipeline Extensibility
>
>
> > On Dec 22, 2016, at 10:51 AM, Howard Butler <howard at hobu.co<mailto:howard at hobu.co>> wrote:
> >
> >
> >> On Dec 21, 2016, at 9:36 PM, Rob Emanuele <rdemanuele at gmail.com<mailto:rdemanuele at gmail.com>>
> wrote:
> >>
> >> If that's correct, I would say instead of "application", some better terms
> would be "tags", "userData", "userTags", or something along those lines.
> >
> > Yes, I was hoping for a better name here. I was also hoping there was a
> standard way that people were extending JSON like this, and that we would
> just support it. I haven't found anything thus far though.
>
> I renamed it to 'userData'. Thanks for the feedback.
>
> Howard
> _______________________________________________
> pdal mailing list
> pdal at lists.osgeo.org<mailto:pdal at lists.osgeo.org>
> http://lists.osgeo.org/mailman/listinfo/pdal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20161229/617ea115/attachment.html>


More information about the pdal mailing list