Tools for Dealing with Spatial Data
This is a list of tools that people in the lab actually use on a regular basis for dealing with spatial data. This is not a collection of every tool that has ever been written for working with spatial data, but a selective list of recommendations for things that we use in the lab.
Rasters
terra is the standard R package for reading raster data and doing standard raster operations. The thing you’re trying to do probably exists in terra somewhere.
landscapemetrics is the de facto standard for landscape ecology metrics, including metrics such as patch density and edge density.
GDAL is a command-line program which handles raster transformations and calculations very quickly. The interface is intimidating, but it’s a better way to deal with huge rasters than trying to load them into R.
Vectors
sf is the standard R package for reading vector data and doing standard vector operations. The thing you’re trying to do probably exists in sf somewhere.
fasterize claims to offer fast rasterization. It’s definitely faster than
raster::rasterize()
, but might not be much faster thanterra::rasterize()
.ogr2ogr is a command-line program for fast filtering, querying, and manipulation of vector data.
LiDAR
- lidR is probably the best R package for reading and processing LiDAR data.
Data Access
- terrainr provides access to a national DEM and orthoimagery from the National Agricultural Imagery Program.
Visualization
- QGIS is a traditional GIS with a graphical user interface. While most CAFRI lab members use R and gdal to do their heavy spatial analyses, we often use QGIS for more exploratory purposes.
- ggplot2 has pretty solid support for building nice-looking maps. Aggregate rasters to at least 120m pixels before trying to plot them; remember that you can’t display more pixels of your map than there are pixels in the image, and if you don’t aggregate, ggplot will.
- ggspatial provides great scale bar and north arrows for ggplot.
- ggsflabel provides more intelligent labeling for maps than anything else available. This package is only available on GitHub; install via
remotes::install_github("yutannihilation/ggsflabel")
.
Other
- spatialsample helps create spatially-separated folds for cross validation, when dealing with data that has spatial structure.
- waywiser provides useful functions for assessing spatial predictions, including methods for determining the area of applicability of a model and for assessing spatial autocorrelation in model residuals.