gg.SpatialPixels | R Documentation |
Uses geom_point
to plot the pixel centers.
Requires the ggplot2
package.
## S3 method for class 'SpatialPixels'
gg(data, ...)
data |
A |
... |
Arguments passed on to |
A geom_tile
return value.
Other geomes for spatial data:
gg()
,
gg.SpatRaster()
,
gg.SpatialGridDataFrame()
,
gg.SpatialLines()
,
gg.SpatialPixelsDataFrame()
,
gg.SpatialPoints()
,
gg.SpatialPolygons()
,
gg.sf()
if (require("ggplot2", quietly = TRUE) &&
requireNamespace("terra", quietly = TRUE) &&
bru_safe_sp()) {
# Load Gorilla data
gcov <- gorillas_sf_gcov()
elev <- terra::as.data.frame(gcov$elevation, xy = TRUE)
pxl <- sf::as_Spatial(sf::st_as_sf(elev, coords = c("x", "y")))
# Turn elevation covariate into SpatialPixels
pxl <- sp::SpatialPixels(pxl)
# Plot the pixel centers
ggplot() +
gg(pxl, size = 0.1)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.