Skip to content
Prev 17022 / 29559 Next

Convex hull clip on 3D Spatial Objects

On 12/20/2012 08:08 PM, Nathalie Morin wrote:
more-dimensional grids can be 'clipped' by 2D objects:

library(sp)
# 10 x 20 x 30 grid:
sgdim = c(10,20,30)
SG = SpatialGrid(GridTopology(rep(0,3), rep(10, 3), sgdim))
SGDF = SpatialGridDataFrame(SG, data.frame(val = rnorm(prod(sgdim))))
image(SGDF, axes=TRUE,col = 'grey')
pol = cbind(c(0,50,50,0,0),c(0,0,50,50,0))
lines(pol)
p = Polygon(pol)
sp = SpatialPolygons(list(Polygons(list(p), "p")))
image(SGDF[sp,], axes=TRUE, add=TRUE)
plot(sp, col='#88888888',add=TRUE)

but not by 3D objects. We have no Spatial* classes yet to represent
convex hulls in more than 2D.