Skip to content
Prev 25426 / 29559 Next

rasterTopolygons: singleparts often needed

Could raster::rasterTopolygons() be modified in future versions
to optionally output singlepart polygons? e.g, in the following
r <-raster(nrow=16, ncol=16)
d <- rep(rep(1:4,rep(4,4)),8)
r[] <- c(d,rev(d))
plot(r)
v <- rasterToPolygons(r,dissolve=TRUE)
plot(v[1,])
dim(v at data)

the new option
v <- rasterToPolygons(r,dissolve=TRUE,single=TRUE)
would result on
plot(v[1,])
displaying one single square and
dim(v at data)
would be 8 rows and 1 column

(equivalent to gdal_polygonize)

Agus