[R-sig-Geo] rasterTopolygons: singleparts often needed

Agustin Lobo alobolistas at gmail.com
Sun Feb 26 12:15:54 CET 2017


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



More information about the R-sig-Geo mailing list