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
?
{
"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 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.
{
"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!