Download a cropped raster for an API request

ca_getrst_stars(
  x,
  out_dir = NULL,
  mask = TRUE,
  merge_geoms = FALSE,
  sidecar = TRUE,
  stop_on_err = TRUE,
  overwrite = FALSE,
  normalize_path = FALSE,
  debug = FALSE,
  quiet = FALSE,
  write_sidecar = deprecated()
)

Arguments

x

A Cal-Adapt API request

out_dir

Where the output TIF files should be written

mask

Mask pixels outside the location of interest with NA values

merge_geoms

Whether to merge geometries, see Details

sidecar

Save a small sidecar file with the TIF file containing additional attribute info

stop_on_err

Stop if the server returns an error

overwrite

Re-download and overwrite existing files

normalize_path

Expand and normalize output file names

debug

Print additional output at the console

quiet

Suppress messages

write_sidecar

Deprecated

Value

A vector of TIF file names. If normalize_path = TRUE the output file names will be expanded (absolute) and use standard slashes for the OS (see normalizePath).

Details

This will download time series cropped raster(s) for your study area, convert them to stars objects, and export them as tif files. If mask = TRUE, pixels values outside the area of interest will be set to NA (mask is ignored for point locations). To get a single raster per dataset that encompasses all the locations, pass merge_geoms = TRUE.

Note this will only work for areas-of-interest small enough for the Cal-Adapt API to handle (i.e., smaller than San Bernadino County). If you want to download rasters for a large area (e.g., the whole state of California) you're better off downloading NetCDF files from the Cal-Adapt data server.

If sidecar = TRUE, a small file with the same base name as the tif will be saved. This sidecar file contains attributes of a space-time-array not preserved by tifs. You can import the tif file back into R as a stars object with ca_read_stars.

This function merely downloads the cropped rasters to disk and returns the filenames. To work with cropped rasters as stars objects within R, import them using ca_read_stars. You can also import the TIF files with other packages or software.

See also