Package 'rlandfire'

Title: Interface to 'LANDFIRE Product Service' API
Description: Provides access to a suite of geospatial data layers for wildfire management, fuel modeling, ecology, natural resource management, climate, conservation, etc., via the 'LANDFIRE' (<https://www.landfire.gov/index.php>) Product Service ('LFPS') API.
Authors: Mark Buckner [aut, cre, cph]
Maintainer: Mark Buckner <[email protected]>
License: MIT + file LICENSE
Version: 1.0.0.9000
Built: 2025-03-08 02:14:54 UTC
Source: https://github.com/bcknr/rlandfire

Help Index


Create extent vector for landfireAPI()

Description

getAOI creates an extent vector in WGS84 from spatial data

Usage

getAOI(data, extend = NULL, sf_order = FALSE)

Arguments

data

A SpatRaster, SpatVector, sf, stars, or RasterLayer (raster) object

extend

Optional. A numeric vector of 1, 2, or 4 elements to increase the extent by.

sf_order

If extend != NULL, logical indicating that the order of the extend vector follows sf::st_bbox() (xmin, ymin, xmax, ymax) when TRUE or terra::extend() (xmin, xmax, ymin, ymax) when FALSE. This is FALSE by default to ensure backwards compatibility with previous versions.

Value

Returns an extent vector ordered xmin, ymin, xmax, ymax with a lat/lon projection.

Examples

r <- terra::rast(nrows = 50, ncols = 50,
  xmin = -123.7835, xmax = -123.6352,
  ymin = 41.7534, ymax = 41.8042,
  crs = terra::crs("epsg:4326"),
  vals = rnorm(2500))
ext <- getAOI(r, c(10, 15))

Find LANDFIRE map zone for use with landfireAPI()

Description

getZone returns the LANDFIRE Map Zone(s) a spatial object intersects or the zone number from the zone name. Currently, only map zones within CONUS are supported.

Usage

getZone(data)

Arguments

data

An sf object or character string with the map zone name.

Value

Returns a numeric vector containing the map zone(s)

Examples

## Not run: 
v <- sf::st_bbox(sf::st_as_sf(data.frame(x = c(-123.7835,-123.6352),
                                        y = c(41.7534,41.8042)),
                             coords = c("x", "y"),
                             crs = 4326)) |>
 sf::st_as_sfc()
zone <- getZone(v)

## End(Not run)

Call the LANDFIRE Product Service (LFPS) API

Description

landfireAPI downloads LANDFIRE data by calling the LFPS API

Usage

landfireAPI(
  products,
  aoi,
  projection = NULL,
  resolution = NULL,
  edit_rule = NULL,
  edit_mask = NULL,
  path = NULL,
  max_time = 10000,
  method = "curl",
  verbose = TRUE
)

Arguments

products

Product names as character vector (see: Products Table)

aoi

Area of interest as character or numeric vector defined by latitude and longitude in decimal degrees in WGS84 and ordered xmin, ymin, xmax, ymax or a LANDFIRE map zone.

projection

Optional. A numeric value of the WKID for the output projection Default is a localized Albers projection.

resolution

Optional. A numeric value between 30-9999 specifying the resample resolution in meters. Default is 30m.

edit_rule

Optional. A list of character vectors ordered "operator class" "product", "operator", "value". Limited to fuel theme products only. (see: LFPS Guide)

edit_mask

Optional. Not currently functional

path

Path to .zip directory. Passed to utils::download.file(). If NULL, a temporary directory is created.

max_time

Maximum time, in seconds, to wait for job to be completed.

method

Passed to utils::download.file(). See ?download.file

verbose

If FALSE suppress all status messages

Value

Returns a landfire_api object with named elements:

  • request - list with elements query, date, url, job_id,dwl_url

  • content - Informative messages passed from API

  • response - Full response

  • status - Final API status, one of "Failed", "Succeeded", or "Timed out"

  • path - path to save directory

Examples

## Not run: 
products <-  c("ASP2020", "ELEV2020", "140CC")
aoi <- c("-123.7835", "41.7534", "-123.6352", "41.8042")
projection <- 6414
resolution <- 90
edit_rule <- list(c("condition","ELEV2020","lt",500), c("change", "140CC", "st", 181))
save_file <- tempfile(fileext = ".zip")
resp <- landfireAPI(products, aoi, projection, resolution, edit_rule = edit_rule, path = save_file)

## End(Not run)

View LFPS products table

Description

viewProducts() opens the LFPS products table in your web browser

Usage

viewProducts()

Value

NULL. Opens the LF products table in your default browser.

Examples

viewProducts()