[pdal] filtering pipeline result

Bradley Chambers brad.chambers at gmail.com
Mon Oct 2 07:36:11 PDT 2017


Giuseppe,

I've been playing around with some ways you could do this in the PDAL
pipeline. It seems we've got lots of things that would be very close, but
not exactly what you'd want. Still looking though.

Pandas and numpy will both do what you want though, with just a slightly
different syntax.

import numpy as np
data = p.arrays[0]
firsts = data[np.where(data['ReturnNumber']==1)]
others = data[np.where(data['ReturnNumber']!=1)]

import pandas as pd
data = p.arrays[0]
df = pd.DataFrame(data)
firsts = df[df['ReturnNumber']==1]
others = df[df['ReturnNumber']!=1]

Do either of these produce the results you are expecting? If so, do you
really need to do it in PDAL, or is the Python-based solution sufficient?

Brad

On Mon, Oct 2, 2017 at 10:00 AM Giuseppe Falcone <falcone.giuseppe at gmail.com>
wrote:

> Thanks for the response, but maybe I didn't explain well what I want.
>
> The pipeline result is like this:
>
> [( 626708.60087012,  4481781.14910498,  7.478, 0, 2, 2, 1, 0, 4, -11., 0,
> 0,  0.,  7.478),( 626708.34087012,  4481780.92910498,  5.418, 0, 1, 3, 1,
> 0, 4, -11., 0, 0,  0.,  5.418),....]
>
> the name of dimensions are:
>  (u'X', u'Y', u'Z', u'Intensity', u'ReturnNumber', u'NumberOfReturns',
> u'ScanDirectionFlag', u'EdgeOfFlightLine', u'Classification',
> u'ScanAngleRank', u'UserData', u'PointSourceId', u'GpsTime',
> u'HeightAboveGround')
>
> I want to split this array in two subarray: the first with element that
> have ReturnNumber (fifth value) dimension = 1 and the second with all
> others elements.
>
> So, I have:
>
> 1st  subarray -> [( 626708.60087012,  4481781.14910498,  7.478, 0, 2, 2,
> 1, 0, 4, -11., 0, 0,  0.,  7.478), ....]
> 2nd subarray -> [( 626708.34087012,  4481780.92910498,  5.418, 0, 1, 3, 1,
> 0, 4, -11., 0, 0,  0.,  5.418), ....]
>
> Thanks
>
> Giuseppe
>
> 2017-10-02 15:52 GMT+02:00 Howard Butler <howard at hobu.co>:
>
>>
>> On Oct 2, 2017, at 5:50 AM, Giuseppe Falcone <falcone.giuseppe at gmail.com>
>> wrote:
>>
>> Hi to all,
>>
>> I have a pipe that elaborate a las file. on the pipe.arrays[0] command I
>> have, as result, a ndarray.
>> I want to split this array in twa subarray: the first with element that
>> have ReturnNumber dimension = 1 and the second with all others elements.
>>
>> There is an efficient way to do this?
>>
>>
>> numpy.where is probably the cleanest way to do this purely in python
>> https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.where.html
>>
>> return_nos = pipe.arrays[0]['ReturnNumber']
>> firsts = np.where(return_nos < 2)
>>
>>
>> Another way would be to write a pipeline with two readers.las, two
>> filters.range, and a filters.merge. Both readers.las would read the same
>> file, and each filters.range would define the range [1] of ReturnNumber you
>> wanted in each set. Then you would use a filters.merge to bring them back
>> together into two separate arrays. This approach is less than ideal due to
>> the fact that you end up reading the same file twice.
>>
>> Howard
>>
>> [1] https://www.pdal.io/stages/filters.range.html#ranges
>>
>
> _______________________________________________
> pdal mailing list
> pdal at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/pdal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20171002/6459879d/attachment-0001.html>


More information about the pdal mailing list