I wanted to leverage information on the ArcGIS Online Living Atlas layers due to their authoritative status and variety of interesting data sets. I was motivated by the recent traumatic news coming out of California about the wildfire incidents occurring over the past month and wanted to leverage the arcgisbinding library along with the leaflet library to visualize any current wildfires remaining. First, the necessary libraries are loaded, however arcgisbinding requires authentication via an active ArcGIS Pro installation on the current workstation. This is verified through the arc.check_product() function.
# load libraries
library(tidyverse)
library(sf) # .shp files/geoprocessing
library(here) # file paths
library(skimr) # data summarizing
library(janitor) # data tidying
library(leaflet) # maps
library(arcgisbinding) # for getting arcgis online data
library(RColorBrewer) # color palettes
# bind to ArcGIS Pro login
arc.check_product()
## product: ArcGIS Pro (13.4.0.55405)
## license: Advanced
## version: 1.0.1.311
First, we will grab the USA Current Wildfires feature service which is hosted on ArcGIS Online. This dataset is derived from the Integrated Reporting of Wildland-Fire Information (IRWIN) service. It contains point and polygon locations of wildfires occurring in the United States. We first specify the REST URL for grabbing the feature service using arc.open, then we can use arc.select to convert into a data frame, then finally use st_as_sf() to convert it into sf object for mapping with the leaflet library
# set feature service URL
firesURL <- "https://services9.arcgis.com/RHVPKKiFTONKtxq3/arcgis/rest/services/USA_Wildfires_v1/FeatureServer/0"
# get arcgis online class object from URL
fires <- arc.open(firesURL)
# convert to data frame
fires_sf <- arc.select(fires)
# convert to sf object
fires_sf <- arc.data2sf(fires_sf)
# glimpse data
glimpse(fires_sf)
## Rows: 325
## Columns: 37
## $ OBJECTID <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, …
## $ IncidentName <chr> "KDF - Rocky Fork Road", "ELK", "VALLEY…
## $ IncidentTypeCategory <chr> "WF", "WF", "WF", "WF", "WF", "WF", "RX…
## $ UniqueFireIdentifier <chr> "2024-KYKYS-240081", "2024-CAKRN-018236…
## $ DailyAcres <dbl> 3.0, NA, 536.0, 5.1, NA, 8.1, 320.0, 30…
## $ CalculatedAcres <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ PercentContained <dbl> NA, NA, 100, NA, NA, NA, NA, 100, NA, N…
## $ ICS209ReportDateTime <dttm> NA, NA, 2024-05-29 20:26:33, NA, NA, N…
## $ FireDiscoveryDateTime <dttm> 2024-03-21 19:41:00, 2024-05-02 00:59:…
## $ DiscoveryAcres <dbl> 3.0, NA, 0.1, 5.1, NA, 8.1, NA, NA, NA,…
## $ POOCounty <chr> "Clay", "Kern", "Modoc", "Kern", "Trini…
## $ POOState <chr> "US-KY", "US-CA", "US-CA", "US-CA", "US…
## $ FireCause <chr> "Undetermined", NA, "Human", "Undetermi…
## $ FireCauseGeneral <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ GACC <chr> "SACC", "OSCC", "ONCC", "OSCC", "ONCC",…
## $ TotalIncidentPersonnel <int> NA, NA, 31, NA, NA, NA, NA, 34, NA, NA,…
## $ IncidentManagementOrganization <chr> NA, NA, "Type 5 IC", NA, NA, NA, NA, "T…
## $ FireMgmtComplexity <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ ResidencesDestroyed <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ OtherStructuresDestroyed <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Injuries <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ Fatalities <int> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ PredominantFuelGroup <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ PredominantFuelModel <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ PrimaryFuelModel <chr> NA, NA, "Heavy Logging Slash", NA, NA, …
## $ ContainmentDateTime <dttm> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ ControlDateTime <dttm> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ FinalAcres <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
## $ IsValid <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ FireOutDateTime <dttm> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA…
## $ ModifiedOnDateTime <dttm> 2025-02-06 14:06:53, 2025-02-05 19:07:…
## $ IncidentTypeKind <chr> "FI", "FI", "FI", "FI", "FI", "FI", "FI…
## $ IrwinID <chr> "39ee010c-1e92-4982-8b86-435815affc0f",…
## $ GlobalID <chr> "b3278e1c-1778-49e5-912b-d90f53c0d0f6",…
## $ ModifiedOnAge <int> 1, 2, 0, 2, 1, 2, 0, 8, 2, 2, 2, 4, 2, …
## $ FireDiscoveryAge <int> 323, 281, 262, 265, 246, 240, 351, 238,…
## $ geom <POINT [°]> POINT (-83.57473 37.06066), POINT…
There are many different data fields available for visualization options. One important note is that when using the arc.data2sf function the resulting data frame will store the geometry in the geom column, rather than an explicit longitude and latitude column. This is actually helpful because leaflet will recognize this single field as storing the geometry without any additional fuss.
For the first map, the set view coordinates were determined by trial and error using Google Maps. Then the fire data is added with a simple red symbology.
# create map of wildfire locations
leaflet() %>%
# set initial view
setView(lng = -99.5154, lat = 36.9162, zoom = 4) %>%
# add dark matter basemap
addProviderTiles(providers$CartoDB.DarkMatter) %>%
addCircles(data = fires_sf,
fillColor = "red",
color = "red",
# set opacity (none)
fillOpacity = 1,
# set radius
radius = 1,
# set name
label = ~IncidentName)
For the second map, a custom color palette is created from 0 to 100 for the percentage contianed field. This time, the fires are clustered with a custom pop-up which uses html formatting to bold text.
# create color palette for wild fire containment
palette <- colorBin("YlOrRd", # yellow to red
# set bins for containment percentage field
bins = c(0, 25, 50, 75, 100))
# create leaflet map of wildfires
leaflet(fires_sf) %>%
# set initial view and zoom
setView(lng = -99.5154, lat = 36.9162, zoom = 4) %>%
# add base map
addProviderTiles(providers$CartoDB.DarkMatter) %>%
# add markers
addCircleMarkers(
# set radius
radius = 2,
# set palette based on percent contained
color = ~palette(PercentContained),
# set stroke properties
stroke = TRUE, weight = 1,
opacity = .75,
fillOpacity = 0.7,
# set pop-up settings
popup = ~paste(
"<strong>Fire Name:</strong>", IncidentName, "<br>",
"<strong>Acres Burned:</strong>", POOCounty, "<br>",
"<strong>Discovery Date:</strong>", FireDiscoveryDateTime, "<br>",
"<strong>Cause:</strong>", FireCause, "<br>",
"<strong>Containment:</strong>", PercentContained, "%"
),
# cluster markers (too many points otherwise, hard to see)
clusterOptions = markerClusterOptions()
) %>%
# add legend
addLegend(
# set pa
pal = palette, values = fires_sf$PercentContained,
title = "Percent Contained", opacity = 0.7, position = "bottomleft"
)
In interpreting the maps, there are many wildfires occurring throughout the United States at varying degrees of severity at any point in time. Most fires are of low severity and contained, however the Palisades fires which wrecked havoc in California are a grim reminder how how catastrophic wildfires can become.