1

I am using R and the current 3x version of the lidR package to process point clouds. Sections of my point cloud are 'unclassified' and I need them to be classified as 'ground'. (These mis-classifications are happening at interstate overpasses.) I would like to manually assign these points their 'ground' classification value. If I were using a GIS, I would select the points using my road polygon and manually reassign their classification value. Is there a workflow in v3x of the lidR package to do this - to change a point's classification based on, in my case, a polygon shapefile?

In v1.6, there was a command called lasclassify that would allow me to create a user defined attribute in the point cloud and assign my own classifications (as in the lasclassify example shown here https://www.rdocumentation.org/packages/lidR/versions/1.6.1/topics/lasclassify). I think it has been long deprecated, though.

There is not much to see, but I provide my code below for anybody who is interested:

library(lidR)
library(rgdal)
mypath<- "c:/myPath/"    
tdat<- readLAS(file.path(myPath,"myLas.las"))

shppath<- myPath
shpname<- "myRoadPolygon"
shape_spdf<- readOGR(dsn = shppath, layer = shpname)
shppoly<- shape_spdf@polygons[[1]]@Polygons[[1]]

###here I would like to select the points in *tdat* by the polygon shapes in *shppoly*...

1 Answer 1

2

The function that replaces lasclassify() from v1.x is merge_spatial(). Below an example were I'm using a polygon of lake to classify as water

library(lidR)

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

las <- readLAS(LASfile)
shp <- shapefile(shpfile)

las <- merge_spatial(las, shp, attribute = "in_poly")
las$Classification[las$in_poly] <- LASWATER
las$in_poly <- NULL
plot(las, color = "Classification")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.