project_extent: Transform a spatiotemporal extent to a different CRS

View source: R/ebirdst-extent.R

project_extentR Documentation

Transform a spatiotemporal extent to a different CRS

Description

Transform an eBird Status and Trends extent object to a different coordinate reference system. This is most commonly required to transform the extent to the sinusoidal CRS used by the eBird Status and Trends rasters.

Usage

project_extent(x, crs)

Arguments

x

ebirdst_extent object; a spatiotemporal extent.

crs

coordinate references system, given either as a proj4string, an integer EPSG code, or a crs object generated with st_crs().

Value

An ebirdst_extent object in the new CRS.

Examples

# construct an ebirdst_extent object
bb_vec <- c(xmin = -80, xmax = -70, ymin = 40, ymax = 47)
bb <- sf::st_bbox(bb_vec, crs = 4326)
bb_ext <- ebirdst_extent(bb)

# transform to sinusoidal projection of rasters
sinu <- "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007 +b=6371007 +units=m +no_defs"
project_extent(bb_ext, crs = sinu)

# also works on polygon extents
poly <- sf::read_sf(system.file("shape/nc.shp", package="sf"))
poly_ext <- ebirdst_extent(poly)
project_extent(poly_ext, crs = sinu)

CornellLabofOrnithology/ebirdst documentation built on Feb. 1, 2023, 8:44 a.m.