SNAPverse R package: snapgrid

This post introduces the snapgrid R package, a data package in the SNAPverse R package ecosystem. It contains a number of convenient raster objects sourced from spatially explicit maps commonly used at SNAP. snapgrid contains a collection of rasterized maps focused on Alaska and Canada, including vegetation input for the ALFRESCO wildfire model, fire management options map layers, domain template layers for the Alaska “statewide” classic ALFRESCO domain, and 1-km ALFRESCO and 2-km climate templates for the Alaska/western Canada domain. This is the second R package member of the SNAPverse introduced here, following snappoly, and like snappoly it is one of the simplest. It provides auxiliary data rather than SNAP data end products. snapgrid is essentially the rasterized map complement to snappoly.

This is a very simple introduction to snapgrid. A subsequent post will provide more examples. That will also be followed by a description of how to integrate maps from snappoly and snapgrid in one analysis when you need to combine multiple source maps, but they are in vector and raster formats, respectively.

Available maps

The following maps are included in the current version of the package:

  • akcan2km: Alaska/western Canada 2-km downscaled climate domain template layer.
  • akcan1km: Alaska/western Canada 1-km ALFRESCO domain template layer.
  • ak1km: “Statewide” classic ALFRESCO domain template layer.
  • swveg: Vegation map layer for the classic “statewide” ALFRESCO model spatial domain.
  • swfmo: Statewide fire management options zones map layer.
  • swratios: Statewide fire management options zone ratios map layer.
  • swflam: Statewide GBM vegetation-mediated, climate-driven landscape flammability mask map layer.

Installation

You can install snapgrid from github with:

# install.packages('devtools')
devtools::install_github("leonawicz/snapgrid")

Basic example

Data sets from the above list can immediately be referred to directly once snapgrid is loaded. To access documentation on the package from R, use ?snapgrid, or for a data set for example, ?swveg.

library(snapgrid)
swveg
#> class       : RasterLayer 
#> dimensions  : 1450, 1374, 1992300  (nrow, ncol, ncell)
#> resolution  : 1000, 1000  (x, y)
#> extent      : -656204.4, 717795.6, 940439.8, 2390440  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0 
#> data source : in memory
#> names       : swveg 
#> values      : 0, 7  (min, max)
raster::plot(swveg)

Via snapgrid, these auxiliary map layers can easily merge into existing analysis workflows in R just by loading the package and referring to their names, or without even explicitly loading the package if you are explicit with the package namespace instead, e.g., by calling snapgrid::swveg. The maps are immediately available in your R session to be used for subsetting other data sets, computing region-specific statistics, or even just providing a quick, convenient graphic of the spatial domain you may we working with for documentation purposes.

Like any of the SNAPverse R packages, even if you are not using other R packages and functions that are part of the broader SNAPverse for analyzing your SNAP data set, snapgrid can be leveraged directly and independently as needed. There is no requirement to couple it in your workflow with other SNAPverse packages that pertain to statistical analysis. The SNAPverse R package ecosystem offers the independence to select only the pieces you need and inject them into you analysis chain where applicable.

Notes

Cleaning and curating is kept to a minimum for this package. Included raster layers cover multiple spatial domains, namely Alaska and Alaska/western Canada, but they all share the NAD83 Alaska Albers Equal Area Conic projection in common:

+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0

Reference

Complete package reference and function documentation

This entry was posted by Matt Leonawicz.
%d bloggers like this: