Setup and Packages
Overview
This section helps you set up your R environment for the Fire Needs Assessment workflow. You’ll start by installing and loading the necessary R packages, and then define your Area of Interest (AOI) using a shapefile.
This code was created in RStudio 2025.09.2+418 “Cucumberleaf Sunflower” Release for windows. If you are using a different version of RStudio, some code may not work correctly.
Before you begin, you will need to:
Set up a new R-Studio project, i.e. “r_landfire_fna”
Create three directories, “inputs”, “rasters”, and “outputs”
Download the file “fna_r.zip” (clicking will initiate the download that will likely land in your “C:” directory) which contains:
- A shapefile for New York State
- BpS attributes file as a .csv
- EVT attributes file as a .csv
Extract the “fna_r.zip” files into the “inputs” sub-directory of your r-studio project.
Create and save a new r-script with a name such as “fna_r_code”.
Once this set up is complete, you should be able to copy/paste the code below into the r script you created above.
1. Install and load required packages
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("data.table")
install.packages("foreign")
install.packages("ggplot2")
install.packages("httr")
install.packages("raster")
install.packages("rlandfire")
install.packages("sf")
install.packages("terra")
install.packages("tidyverse")
library(data.table)
library(foreign)
library(ggplot2)
library(raster)
library(rlandfire)
library(sf)
library(terra)
library(tidyverse)2. Define your AOI
If you are using your own shapefile for the AOI, remember to replace the current boundary.shp (and associated files) in your inputs folder.
The code below will read in your aoi polygon and project it to the same projection as the LANDFIRE data. This will allow you to download the correct data extent and clip those downloaded data to your project area boundary.
# read the shapefile of the polygon area you're interested in
aoi <- st_read("inputs/boundary.shp", quiet = TRUE)
plot(st_geometry(aoi))
# projection
aoi <- st_transform(aoi, crs = 5070) # NAD83 / Conus AlbersStill have questions? LANDFIRE is here to help.
Ask the LANDFIRE Helpdesk (email link).
Search and subscribe to the LANDFIRE YouTube Channel (see tutorials, Office Hours, quick demonstrations).
Join an Office Hour (monthly meeting with open format Q & A with LANDFIRE experts).
Schedule a meeting (email link) with TNC’s LANDFIRE Team.