Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmable filter can add dimensions to context #447

Merged
merged 1 commit into from Sep 12, 2014

Conversation

gadomski
Copy link
Member

@gadomski gadomski commented Sep 9, 2014

Using one or more add_dimension options on a programmable filter will instruct the filter to add those dimensions to the primary PointContext. This way, the programmable filter can set dimensions that might not be present on the PointContext.

My use case for this is manually scaling and "renaming" a dimension coming in from a reader, e.g. this pipeline:

<?xml version="1.0" encoding="utf-8"?>
<Pipeline version="1.0">
    <Writer type="drivers.las.writer">
        <Option name="filename">output.las</Option>
        <Option name="discard_high_return_numbers">true</Option>
        <Filter type="filters.programmable">
            <Option name="source">
import numpy
def reflectance_to_intensity(ins, outs):
    ref = ins["Reflectance"]
    min = numpy.amin(ref)
    max = numpy.amax(ref)
    outs["Intensity"] = (65536 * (ref - min) / (max - min)).astype(numpy.uint16)
    return True
            </Option>
            <Option name="function">reflectance_to_intensity</Option>
            <Option name="module">pyrxp</Option>
            <Option name="add_dimension">Intensity</Option>
            <Reader type="drivers.rxp.reader">
                <Option name="filename">/home/vagrant/PDAL/test/data/rxp/130501_232206_cut.rxp</Option>
            </Reader>
        </Filter>
    </Writer>
</Pipeline>

The rxp reader, which produces the "Reflectance" value, comes from this branch.

Using one or more `add_dimension` options on a programmable filter will
instruct the filter to add those dimensions to the primary
PointContext. This way, the programmable filter can set dimensions that
might be not present on the PointContext at first.
@hobu
Copy link
Member

hobu commented Sep 10, 2014

So filters.programmable is going to be the way to add dimensions "slots" to a pipeline? Works for me.

@gadomski
Copy link
Member Author

I thought about adding another filter, but since my use case is specific I thought I'd keep it simple for now. I'm open to feedback on that idea, though.

hobu added a commit that referenced this pull request Sep 12, 2014
Programmable filter can add dimensions to context
@hobu hobu merged commit 943cbbc into PDAL:master Sep 12, 2014
@gadomski gadomski deleted the programmable-add-dimension branch September 12, 2014 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants