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

Unexpected behaviour classify_roi() #732

Open
zoeschindler opened this issue Nov 21, 2023 · 3 comments
Open

Unexpected behaviour classify_roi() #732

zoeschindler opened this issue Nov 21, 2023 · 3 comments
Assignees
Labels
Bug A bug in the package

Comments

@zoeschindler
Copy link

zoeschindler commented Nov 21, 2023

Hello, I have an issue with classify_roi().
I want to classify points within some polygons (derived from buffered lines) as a different class than the remaining points.
But when I read my data in using readTLSLAS() instead of readLAS(), I get weird results. I made some dummy data: https://drive.google.com/file/d/1OOl4_vRYCIRSmx-Ey7cflgZv_s-y9l07/view?usp=sharing

Here is the code:

# load packages
library(lidR)
library(sf)

# read pointcloud
las <- readTLSLAS("test.las")
crs(las) <- "EPSG:32632"

# load shapes
shp_lines <- st_read("test.shp")
shp_polys <- st_buffer(shp_lines, 0.025)

# show pointcloud & shapes
plot(las)
plot(shp_polys)

# classify using lines
las$Classification <- LASUNCLASSIFIED
las <- classify_poi(las, class = LASGROUND, roi = shp_polys)

# show results
plot(las, color = "Classification")
plot(filter_poi(las, Classification == LASGROUND))

Polygons:
grafik

Result when using readLAS() (expected result):
grafik

Result when using readTLSLAS() (unexpected result):
grafik

@Jean-Romain Jean-Romain self-assigned this Nov 21, 2023
@Jean-Romain Jean-Romain added the Bug A bug in the package label Nov 21, 2023
@Jean-Romain
Copy link
Collaborator

Thank you for the nice and easily reproducible example. I confirm the bug.

@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Nov 22, 2023

Minimal Reproducible example

las <- readLAS("issue 732/test.las")
st_crs(las) <- "EPSG:32632"
shp_lines <- st_read("~/Téléchargements/lidR issues/issue 732/test.shp")
shp_polys <- st_buffer(shp_lines, 0.025)
sfc <- sf::st_geometry(shp_polys)
sum(lidR:::point_in_polygons(las, sfc), na.rm = T)
#> TLS: 101111
#> ALS: 469881

By the way @zoeschindler do not use crs(). Use st_crs(). crs() will be removed in next version to avoid problem on CRAN with old geospatial package (raster, sp)

@zoeschindler zoeschindler closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
@zoeschindler zoeschindler reopened this Nov 22, 2023
@r-lidar r-lidar deleted a comment from zoeschindler Nov 22, 2023
@Jean-Romain
Copy link
Collaborator

Jean-Romain commented Nov 22, 2023

Fixed with a temporary fix. My octree has a problem, so I disabled the octree and used another spatial indexing structure by default. I keep the issue open because I must repair the octree.

@Jean-Romain Jean-Romain reopened this Nov 22, 2023
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