Reputation: 1271
Is there a (easy) way to convert a SpatialPixelsDataFrame (from krige) to e.g. a SpatialPolygonsDataFrame (vectorgraphic instead of pixelgraphic).
It would be fine to set value ranges and interpolate the raster to a polygon or use another krige method that generates a SpatialPolygonsDataFrame. I'm looking forward to a simple example.
krige example: i.e. in the book https://oscarperpinan.github.io/spacetime-vis/ 8.1.5 Spatial Interpolation, complete source https://github.com/oscarperpinan/spacetime-vis/blob/master/bubble.R
library(gstat)
airGrid <- spsample(NO2sp, type="regular", n=1e5)
gridded(airGrid) <- TRUE
airKrige <- krige(mean ~ 1, NO2sp, airGrid)
spplot(airKrige["var1.pred"],
col.regions=colorRampPalette(airPal)) + ...
Upvotes: 1
Views: 1010
Reputation: 47081
Something like this might work:
library(raster)
x <- raster(airKrige["var1.pred"])
y <- cut(x, c(10,20,30,40,50,60,70))
z <- rasterToPolygons(y, dissolve=TRUE)
spplot(z)
Upvotes: 2