gg.SpatialPixelsDataFrame {inlabru} | R Documentation |
Geom for SpatialPixelsDataFrame objects
Description
Coerces input SpatialPixelsDataFrame to data.frame and uses geom_tile
to plot it.
Requires the ggplot2
package.
Usage
## S3 method for class 'SpatialPixelsDataFrame'
gg(data, mapping = NULL, crs = NULL, mask = NULL, ...)
Arguments
data |
A SpatialPixelsDataFrame object. |
mapping |
Aesthetic mappings created by |
crs |
A sp::CRS object defining the coordinate system to project the data to before plotting. |
mask |
A SpatialPolygon defining the region that is plotted. |
... |
Arguments passed on to |
Value
A geom_tile
return value.
See Also
Other geomes for spatial data:
gg()
,
gg.SpatRaster()
,
gg.SpatialGridDataFrame()
,
gg.SpatialLines()
,
gg.SpatialPixels()
,
gg.SpatialPoints()
,
gg.SpatialPolygons()
,
gg.sf()
,
gm()
Examples
if (require(ggplot2, quietly = TRUE) &&
bru_safe_sp() &&
require("sp")) {
# Load Gorilla data
data("gorillas", package = "inlabru")
# Plot Gorilla elevation covariate provided as SpatialPixelsDataFrame.
# The same syntax applies to SpatialGridDataFrame objects.
ggplot() +
gg(gorillas$gcov$elevation)
# Add Gorilla survey boundary and nest sightings
ggplot() +
gg(gorillas$gcov$elevation) +
gg(gorillas$boundary) +
gg(gorillas$nests)
# Load pantropical dolphin data
data("mexdolphin", package = "inlabru")
# Plot the pantropical survey boundary, ship transects and dolphin sightings
ggplot() +
gg(mexdolphin$ppoly) + # survey boundary as SpatialPolygon
gg(mexdolphin$samplers) + # ship transects as SpatialLines
gg(mexdolphin$points) # dolphin sightings as SpatialPoints
# Change color
ggplot() +
gg(mexdolphin$ppoly, color = "green") + # survey boundary as SpatialPolygon
gg(mexdolphin$samplers, color = "red") + # ship transects as SpatialLines
gg(mexdolphin$points, color = "blue") # dolphin sightings as SpatialPoints
# Visualize data annotations: line width by segment number
names(mexdolphin$samplers) # 'seg' holds the segment number
ggplot() +
gg(mexdolphin$samplers, aes(color = seg))
# Visualize data annotations: point size by dolphin group size
names(mexdolphin$points) # 'size' holds the group size
ggplot() +
gg(mexdolphin$points, aes(size = size))
}
[Package inlabru version 2.11.1 Index]