I want to make a simple clip with my .las 3D-Pointcloud.
Therefor I use the lasclip()
function.
Import .las:
lidar <- readLAS("~/data.las")
lidar
gives me
class : LAS (LASF v1.2)
memory : 774.7 Mb
extent : 3403298 , 3403640 , 5286553 , 5286831 (xmin, xmax, ymin, ymax)
area : 62291.4 m² (convex hull)
points : 11946448 points, 4704414 pulses
density : 191.78 points/m², 75.52 pulses/m²
field names : X Y Z gpstime Intensity ReturnNumber NumberOfReturns Classification ScanAngle R G B pulseID
coord. ref. : +init=epsg:31467 +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +datum=potsdam +units=m +no_defs +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7
Import the clip:
site <- readOGR(dsn = "~/directory", layer = "clipshape")
site
gives me:
class : SpatialPolygonsDataFrame
features : 1
extent : 3403372, 3403590, 5286594, 5286817 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=0 +lon_0=9 +k=1 +x_0=3500000 +y_0=0 +datum=potsdam +units=m +no_defs +ellps=bessel +towgs84=598.1,73.7,418.2,0.202,0.045,-2.455,6.7
variables : 1
names : id
value : 1
Ok now I want to clip it:
lasclip(lidar, site)
and I get the following Error:
Error: Geometry not supported
I am working in an environment where I cannot use pdal with python for several reasons.
How can I get cliplas()
working?
Best Answer
Perfect answer by @andre-silva but let met add few informations. In
lidR 1.5.0
you will be able to clip using aSpatialPolygonDataFrame
. In that case you will get alist
of LAS objects (one per polygon).Also
lasclip
will be compatible with aLAScatalog
. You don't need anymore to load the entire tile to extract a single polygon. Just extract the polygon.But be careful. You can't clip a
SpatialPolygonDataFrame
from aLAScatalog
. It is technically possible but it has been disabled for two reasons. The first one is memory safety. Indeed, assuming you have 1000 tiles over 1000 km² and a shapefile with hundreds of large polygons, this would load too much data. In order to prevent R crash with bad usage this option is disabled. The second reason is multipart polygonsRegarding multipart polygons, the
rlas
package only supports single polygon extraction. Thus it is extremely easy to efficiently extract aSpatialPolygon
. ForSpatialPolygons
(potentially multipart polygons with holes) this is not currently natively supported. It requires more computation that are not memory efficient. This is why it is not supported yet but this will be added inlidR
later. Edit: it is supported as of version 2.0.0