ggspatial (version 0.2.1)

geom_spatial.Raster: Spatial Geometry for Raster* Objects

Description

Similar to the geom_spatial family for Spatial* objects, this method plots a spatial raster as a spatial raster. Note that projecting (or un-projecting) this layer will likely result in odd results (namely that geom_raster will not function properly or at all). As a convenience, ggraster() is provided, which replaces the call to coord_map() from ggspatial with a call to coord_fixed().

Usage

# S3 method for Raster
geom_spatial(data, mapping = NULL, show.legend = TRUE,
  inherit.aes = FALSE, position = "identity", crsfrom = crsfrom,
  crsto = crsto, geom = "raster", stat = "identity", ...)

ggraster(data, mapping = NULL, ...)

Arguments

data

A Raster* object

mapping

A mapping

show.legend

Should the legend be shown for this layer?

inherit.aes

Should aesthetics be inherited from the base plot?

position

The position to apply (should probably always be 'identity')

crsfrom

Override the source projection

crsto

Override the source projection

geom

The geometry to use. Defaults to raster (obviously), but could also be another value if used with a different stat (e.g. contour)

stat

The stat to apply. Defaults to 'identity', but could be something else like 'contour', stat_rgba ("rgba"), or stat_project ("project").

...

Further arguments passed to the stat/geom

Value

A ggplot2 layer

Examples

Run this code
# NOT RUN {
# standard ggplot syntax
ggplot() + geom_spatial(longlake_osm, aes(fill = band1)) + coord_fixed()
# }
# NOT RUN {
# or use ggraster()
ggraster(longlake_osm, aes(fill = band1))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab