Closed bw4sz closed 6 years ago
You are the second this week to ask me for this feature. This is not complex to do. I can do it on Monday.
But you missed a point. A generic function must also consider multi-part polygons and polygons with holes. It is a bit more complex than simply iterate through polygons. lasclassify
already supports SpatialPolygonDataFrame
and can be used as basis for such function.
sounds good. I am happy to help in anyway. It might also be worth having a flag to spit out a list, or select multiple features. For example,I might want to see a set of polygons (id %in% c(1,2,3)). I can think of a couple ways to do this. As I said, I just started playing with the package. Thanks for the work.
Btw looking at your code I can't see any obvious interest of such feature in your specific case. If you want to compute some metrics for each tree you can use tree_metrics
. And if you really want to split the point cloud you can use lasfilter
and filter for each tree ID
.
Anyway this feature might be useful. The difficulty is not to program it for LAS
objects but also make it compatible in a seamless way for LAScatalog
objects.
Here a ready to use function to split a LAS
object using a SpatialPolygonDataFrame
lassplitspdf = function(las, spdf)
{
id = lidR:::classify_from_shapefile(las, spdf)
X = split(las@data, id)
X = lapply(X, LAS, header = las@header)
return(X)
}
Great. This implementation works well because if someone wanted a group of trees, they could assign the ID field to encompass a set.
It would be nice to be able to directly grab a list of point clouds from the output of lastrees object. Let me know if something like this exists, if not I can submit a PR.
I'm working with a toy function similar to this.
What I was hoping for was to be able to clip the las based on the contents of a
SpatialPolygonsDataFrame
.which would return a list of LAS objects.
but docs suggest I need to decompose this into its coords for a single polygon.
The xpoly coords for a sample poylgon (id ==10) are
and the y poly coords are
We could just iterate through every polygon and save it and return a list? Thoughts?
First few hours with your package, great work @Jean-Romain. Hopefully I can make myself useful in contrib. I think others would be excited for a direct method. This would be my first PR to this package, so give me a sense for conventions (naming, inputs, regenerate the roxygen?).