Type: Package
Title: Interface to 'LANDFIRE Product Service' API
Version: 2.0.0
Maintainer: Mark Buckner <mab677@cornell.edu>
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/) Product Service ('LFPS') API.
License: GPL (≥ 3)
Encoding: UTF-8
URL: https://github.com/bcknr/rlandfire
BugReports: https://github.com/bcknr/rlandfire/issues
RoxygenNote: 7.3.2
Imports: curl, httr2, sf, terra, utils
Suggests: foreign, httptest2, httr, knitr, lifecycle, raster, rmarkdown, stars, testthat (≥ 3.0.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
Depends: R (≥ 4.1.0)
NeedsCompilation: no
Packaged: 2025-04-28 22:17:10 UTC; mark
Author: Mark Buckner ORCID iD [aut, cre, cph]
Repository: CRAN
Date/Publication: 2025-04-28 22:30:02 UTC

rlandfire: 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/) Product Service ('LFPS') API.

Author(s)

Maintainer: Mark Buckner mab677@cornell.edu (ORCID) [copyright holder]

See Also

Useful links:


Cancel an active LANDFIRE Product Service (LFPS) API job

Description

cancelJob() sends a request to cancel a LFPS API request

Usage

cancelJob(job_id)

Arguments

job_id

The job ID of the LFPS API request as a character string

Value

NULL. Prints a message to the console about the job status.

Examples

## Not run: 
products <-  c("ASP2020", "ELEV2020", "230CC")
aoi <- c("-123.7835", "41.7534", "-123.6352", "41.8042")
email <- "email@example.com>"

resp <- landfireAPIv2(products, aoi, email, background = TRUE)

job_id <- resp$request$job_id #Get job_id from a previous request
cancelJob("job_id")

## End(Not run)

Check the status of an existing LANDFIRE Product Service (LFPS) request

Description

checkStatus checks if a previous request is complete and downloads available data

Usage

checkStatus(landfire_api, verbose = TRUE, method = "curl")

Arguments

landfire_api

landfire_api object returned from landfireAPIv2()

verbose

If FALSE suppress all status messages

method

Passed to utils::download.file(). See ?download.file or use "none" to skip download and use landfire_vsi()

Value

Returns a landfire_api object with named elements:

Examples

## Not run: 
products <-  c("ASP2020", "ELEV2020", "230CC")
aoi <- c("-123.7835", "41.7534", "-123.6352", "41.8042")
email <- "email@example.com"
resp <- landfireAPIv2(products, aoi, email, background = TRUE)
checkStatus(resp)

## End(Not run)

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)


Check if the LFPS API is available

Description

healthCheck() checks if the LPFS API is available

Usage

healthCheck()

Value

NULL. Prints a message to the console about the current LFPS status.

Examples

## Not run: 
healthCheck()

## End(Not run)

Depreciated: Call the LANDFIRE Product Service (LFPS) API

Description

Depreciated: landfireAPI() is no longer supported due to updates to the LFPS API. Use landfireAPIv2() instead.

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 or use "none" to skip download and use landfire_vsi()

verbose

If FALSE suppress all status messages

Value

Returns a landfire_api object with named elements:

Examples

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

## End(Not run)

Call the LANDFIRE Product Service (LFPS) API

Description

landfireAPIv2 downloads LANDFIRE data by calling the LFPS API

Usage

landfireAPIv2(
  products,
  aoi,
  email,
  projection = NULL,
  resolution = NULL,
  edit_rule = NULL,
  edit_mask = NULL,
  priority_code = NULL,
  path = NULL,
  max_time = 10000,
  method = "curl",
  verbose = TRUE,
  background = FALSE
)

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.

email

Email address as character string. This is a required argument for the LFPS v2 API. See the LFPS Guide for more information. Outside of the LFPS API request, this email address is not used for any other purpose, stored, or shared by rlandfire.

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" where "operator class" is one of "condition", "ORcondition", or "change". Edits are limited to fuel theme products only. (see: LFPS Guide)

edit_mask

Optional. Path to a compressed shapefile (.zip) to be used as an edit mask. The shapefile must be less than 1MB in size and must comply with ESRI shapefile naming rules.

priority_code

Optional. Priority code for wildland fire systems/users. Contact the LANDFIRE help desk for information (helpdesk@landfire.gov)

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

background

If TRUE, the function will return immediately and the job will run in the background. User will need to check the status of the job manually with checkStatus().

Value

Returns a landfire_api object with named elements:

Examples

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

## End(Not run)

Read in LANDFIRE products using the GDAL ⁠virtual file system⁠

Description

landfire_vsi() opens a request LANDFIRE GeoTIFF using the GDAL ⁠virtual file system⁠ (VSI).

Usage

landfireVSI(landfire_api)

Arguments

landfire_api

A landfire_api object created by landfireAPIv2()

Details

The GDAL virtual file system allows you to read in LANDFIRE products without having to download the file to your local machine within 60 minutes of the request or if the file already exists on your local machine without having to unzip it.

Value

SpatRaster object of the requested LANDFIRE product/s

Examples

## Not run: 
aoi  <- c("-113.79", "42.148", "-113.56", "42.29")
email <- "email@example"
rast <- landfireAPIv2(products = "240EVC",
                      aoi = aoi, email = email,
                      method = "none")  |>
        landfireVSI()

## 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

## Not run: 
viewProducts()

## End(Not run)