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

lasmergespatial bug if merging with shapefile attribute #223

Closed
NatKatUP opened this issue Feb 18, 2019 · 6 comments
Closed

lasmergespatial bug if merging with shapefile attribute #223

NatKatUP opened this issue Feb 18, 2019 · 6 comments
Assignees
Labels
Bug A bug in the package

Comments

@NatKatUP
Copy link

NatKatUP commented Feb 18, 2019

Hi,
I have a bug where lasmergespatial(las, polygon, "ID") assigns the SpatialPolygonDataframe's attribute ID not to the points that lay within the polygons, but to the first length(polygon) of points in subsequent order.

They are in the same projection and lasclassify worked for the same kind of las dataset and polygon structure.

I would upload the las-file, but it's kinda big, so maybe someone comes up with a solution without.

Thanks,
NatKat

@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Feb 18, 2019

If you can't share the file, at least show me the code and an image of the input/output because I don't understand what is going wrong. Did you try to reproduce with data provided with the package?

@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Feb 18, 2019

Easy to reproduce. Bug confirmed. I should be able to fix it within few hours.

LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
shp     <- system.file("extdata", "lake_polygons_UTM17.shp", package = "lidR")

las     <- readLAS(LASfile, select = "xyz")
lakes   <- shapefile(shp)

las <- lasmergespatial(las, lakes, "ANY")
table(las@data$ANY)

las <- lasmergespatial(las, lakes, "LAKENAME_1")
table(las@data$LAKENAME_1)

@Jean-Romain Jean-Romain self-assigned this Feb 18, 2019
@Jean-Romain Jean-Romain added the Bug A bug in the package label Feb 18, 2019
@Jean-Romain
Copy link
Collaborator

Fixed

@Jean-Romain Jean-Romain changed the title lasmergespatial bug? lasmergespatial bug if merging with shapefile attribute Feb 18, 2019
@NatKatUP
Copy link
Author

I was out of office for two days, thanks for solving this problem so fast!
And thanks again for the comprahensive package, I am writing my master's thesis and use lidR extensively.

@NatKatUP
Copy link
Author

Unfortunately there is another problem with lasmergespatial:
I have a polygon containing the ground projected crown shapes of a tree stand and want to give my point cloud points that belong to the trees their IDs.
It seems like my polygons change their shape within the funtion. It looks like the polygons would maybe get rasterized and resampled, at least their shape is much simpler and if i color the point cloud by ID in the RGL viewer, you see that not all points got the id (see screenshot).
unbenannt
I attach a las subset and my shape file.
shapes.zip
test_subset.zip

@Jean-Romain
Copy link
Collaborator

Could you please open a new issue with the data, the image, the explanation + a reproducible code. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in the package
Projects
None yet
Development

No branches or pull requests

2 participants