Using auxiliary data in FIESTA can help enhance your result. One resource for auxiliary data is the R rsi package

Learn more about the R rsi package here (https://github.com/Permian-Global-Research/rsi/tree/main)

SET UP

This section will include the following

Set up R packages

library("rsi")
library("FIESTA")
spectral_indices()

aoi <- sf::st_point(c(-107.34041007184679, 44.48965583058798))
aoi <- sf::st_set_crs(sf::st_sfc(aoi), 4326)
aoi <- sf::st_buffer(sf::st_transform(aoi, 5070), 1000)

landsat_image <- get_stac_data(
  aoi,
  start_date = "2022-06-01",
  end_date = "2022-06-30",
  pixel_x_size = 30,
  pixel_y_size = 30,
  asset_names = c("red"),
  stac_source = "https://planetarycomputer.microsoft.com/api/stac/v1/",
  collection = "landsat-c2-l2",
  mask_band = "qa_pixel",
  mask_function = landsat_mask_function,
  output_filename = tempfile(fileext = ".tif"),
  item_filter_function = landsat_platform_filter,
  platforms = c("landsat-9", "landsat-8")
)

USE DATA IN FIESTA

Translate downloaded data to Auxiliary data

# Set up data necessary for spGetAuxiliary function
WYbhfn <- system.file("extdata",
                      "sp_data/WYbighorn_adminbnd.shp",
                      package = "FIESTA")

# Import downloaded data as raster file
library(terra)
data <- rast(landsat_image)

# Get Wyoming Plots
WYspplt <- spMakeSpatialPoints(xyplt = WYplt,
                               xy.uniqueid = "CN",
                               xvar = "LON_PUBLIC",
                               yvar = "LAT_PUBLIC",
                               xy.crs = 4269)

# Run sp Get Auxiliary
rastlst.cont <- data
rastlst.cont.name <- "red"

auxiliaryData <- spGetAuxiliary(xyplt = WYspplt,
                                uniqueid = "CN",
                                unit_layer = WYbhfn,
                                unitvar = NULL,
                                rastlst.cont = rastlst.cont,
                                rastlst.cont.name = rastlst.cont.name,
                                rastlst.cont.stat = "mean",
                                keepNA = FALSE,
                                showext = FALSE,
                                savedata = FALSE)

Use auxiliary data in Small Area population

# Setting up necessary data for modSApop function
WYbhdistfn <- system.file("extdata", "sp_data/WYbighorn_districtbnd.shp", package="FIESTA")

smallbnd <- WYbhdistfn
smallbnd.domain <- "DISTRICTNA"

SApltdat <- spGetPlots(bnd = WYbhdistfn,
                       xy_datsource = "obj",
                       xy = WYplt,
                       xy_opts = list(xy.uniqueid = "CN", xvar = "LON_PUBLIC", 
                                      yvar = "LAT_PUBLIC", xy.crs = 4269),
                       datsource = "obj",
                       istree = TRUE,
                       isseed = TRUE,
                       dbTabs = list(plot_layer = WYplt, cond_layer = WYcond,
                                     tree_layer = WYtree, seed_layer = WYseed),
                       eval = "custom",
                       eval_opts = list(invyrs = 2011:2013),
                       showsteps = TRUE,
                       returnxy = TRUE)

# Use Auxiliary Data in modSApop
SApopdat <- modSApop(pltdat = SApltdat, auxdat = auxiliaryData,
                     smallbnd = WYbhdistfn, smallbnd.domain = smallbnd.domain)


USDAForestService/FIESTA documentation built on April 5, 2025, 4:13 a.m.