raytrix_set_canvas: set/get the canvas of the rayshader-ratrix project

raytrix_set_canvasR Documentation

set/get the canvas of the rayshader-ratrix project

Description

To enable the downloading of rayshader-readable data for a desired extent, it is necessary to set the rayshader-ratrix scene canvas using one of the set_canvas_x() functions. See details for additional info.

Usage

set_canvas(bounds, projection)

set_canvas_world(projection = "+proj=longlat +datum=WGS84")

set_canvas_sf(.sf, mask = F)

set_canvas_raster(.raster, mask = F)

set_canvas_centroid(
  lat,
  long,
  radius = 5000,
  projection = "+proj=longlat +datum=WGS84"
)

get_canvas(res)

canvasExent()

Arguments

bounds

numeric vector of length 4. e.g. c(xmin, xmax, ymin, ymax)

projection

...

.sf

The sf/sfc object used to set the extent and projection of the canvas

mask

Default is F. NOT WORKING YET!

.raster

The raster object used to set the extent and projection of the canvas

lat

...

long

...

radius

...

res

A resolution (i.e pixel dimensions) in the units of the canvas crs (⁠get_canvas()$⁠)

Details

set_canvas() offers the most control over the extent and projection of the raytrix canvas. Use set_canvas_world() for a basic WGS84 extent of the world; this is deliberately simple, for alternative global projections use set_canvas(). set_canvas_sf() sets the canvas from an sf or sfc object; this can be especially useful when you intend to plot sf features as overlays. set_canvas_centroid() allows for the provision of lat long coordinates and a buffer (in meters) around that point to set the extent; this function takes WGS84 coords by default (although this can be changed) but will always convert to Pseudo Mercator for convenience. To retrieve this information use get_canvas() which returns a list including: extent, projection and (if res is provided) dimension. canvasExent() returns a raytrix extent object which is a copy of a raster Extent object. This can be used in combination with rayshader functions such as generate_polygon_overlay() to provide the extent of the topography matrix.

Examples

# set canvas with Universal Polar Stereographic
set_canvas(c(-4e7,  4e7, -4e7,  4e7 ),'+proj=ups')
get_canvas()
get_canvas(4e4)

# set canvas with tilted perspective...
set_canvas(c(-3.8e6,  3.8e6, -3.8e6,  3.8e6 ),'+proj=tpers +h=5500000 +lat_0=40')
get_canvas(4e4)

# set WGS84 global extent
set_canvas_world()
get_canvas(0.7)

# set canvas for Mt. St Helens
set_canvas_centroid(46.200732, -122.187082, radius = 7000)
get_canvas(10)

# set canvas with sf object.
library(sf)
demo(nc, ask = FALSE, echo = FALSE)
set_canvas_sf(nc)
get_canvas(7e-3)

canvasExent()


h-a-graham/raytrix documentation built on Nov. 19, 2024, 10:27 p.m.