layer_spatial.stars: Spatial ggplot2 layer for stars objects

View source: R/layer-spatial-stars.R

layer_spatial.starsR Documentation

Spatial ggplot2 layer for stars objects

Description

This is intended for use with RGB(A) rasters (e.g., georeferenced imagery or photos). To work with bands as if they were columns, use df_spatial and geom_raster.

Usage

## S3 method for class 'stars'
layer_spatial(
  data,
  mapping = NULL,
  interpolate = NULL,
  is_annotation = FALSE,
  lazy = FALSE,
  dpi = 150,
  options = character(0),
  ...
)

## S3 method for class 'stars'
annotation_spatial(data, mapping = NULL, interpolate = NULL, ...)

StatSpatialStars

StatSpatialStarsAnnotation

StatSpatialStarsDf

GeomSpatialStars

Arguments

data

A stars object

mapping

Currently, only RGB or RGBA rasters are supported. In the future, one may be able to map specific bands to the fill and alpha aesthetics.

interpolate

Interpolate resampling for rendered raster image

is_annotation

Lets raster exist without modifying scales

lazy

Delay projection and resample of raster until the plot is being rendered

dpi

if lazy = TRUE, the dpi to which the raster should be resampled

options

GDAL options for warping/resampling (see st_warp)

...

Passed to other methods

Format

An object of class StatSpatialStars (inherits from Stat, ggproto, gg) of length 3.

An object of class StatSpatialStars (inherits from StatSpatialStars, Stat, ggproto, gg) of length 3.

An object of class StatSpatialStarsDf (inherits from Stat, ggproto, gg) of length 5.

An object of class GeomSpatialStars (inherits from Geom, ggproto, gg) of length 5.

Value

A ggplot2 layer

Examples



library(ggplot2)
load_longlake_data(
  which = c(
    "longlake_osm",
    "longlake_depth_raster"
  ),
  raster_format = "stars"
)
ggplot() +
  layer_spatial(longlake_osm)

ggplot() +
  layer_spatial(longlake_depth_raster) +
  scale_fill_continuous(
    na.value = NA,
    type = "viridis"
  )


ggspatial documentation built on Aug. 17, 2023, 5:13 p.m.