Tidy and geospatial interpolated grids
tidyst_intergrid.RdTidy and geospatial interpolated grids for 2-dimensional gridded data.
Usage
tidy_intergrid(data, attrib, cellsize, verbose=FALSE)
st_intergrid(x, attrib, cellsize, verbose=FALSE)Details
Any missing grid cells are inferred so there are no gaps in the output, and the attribute value to set to 0. For any other grid cells with missing attribute values, the attributate is also set to 0. tidy_overgrid/st_overgrid is usually deployed on gridded data from third parties, where geometries are excluded/varying to reduce storage requirements, but tidy_as_kde/st_as_kde require complete regular rectangular grids.
Examples
## geospatial quasi density estimate
library(ggplot2)
data(ales_grid, package="eks")
## incomplete 1 km x 1 km grid
## ind = #individuals in grid cells
gs <- ggplot() + theme_sf() +
colorspace::scale_fill_continuous_sequential(palette="Heat", breaks=seq(0,6000,by=1000))
gs + geom_sf(data=ales_grid, aes(fill=ind))
## complete regular interpolated 1 km x 1 km grid
ales_sgrid <- st_intergrid(ales_grid, attrib="ind", cellsize=c(1000,1000))
gs + geom_sf(data=ales_sgrid, aes(fill=ind))
## geom_sf KDE plot
ales_skde <- st_as_kde(ales_sgrid)
ggplot(ales_skde) + theme_sf() +
geom_sf(data=st_get_contour(ales_skde), aes(fill=contperc))