When working with raster data such as satellite imagery, it is sometimes necessary to combine multiple adjacent, possibly overlapping smaller rasters into a single large raster that covers the entire area of interest. This example demonstrates one way to use R to create a raster image mosaic while also applying a resampling algorithm to align the inputs.
R includes a rich set of plotting functions that can be applied to spatial data. This example demonstrates how to generate publication-quality maps using these functions, which in many cases can eliminate the need to use dedicated GIS software.
The ESRI Shapefile is a widely used file format for storing vector-based geopatial data (i.e., points, lines, and polygons). This example demonstrates use of several different R packages that provide functions for reading and/or writing shapefiles.
Geospatial data are usually only useful when associated with a spatial reference system (SRS). In a nutshell, this is the information needed to relate spatial coordinates in the dataset to actual positions on our planet, and by extension to relate spatial datasets to one another. When using programmatic tools to convert spatial data into a different SRS (e.g., when performing map projection), and even just to specify the SRS when this information is missing from the data source itself, you will sometimes need to express it in a standard format that the program can understand. There are several common ways to do this.
Download data and R Code for this example
Given a set of point locations (e.g., field sightings of some organism) and polygons circumscribing areas of interest (e.g., U. S. National Parks), you might find yourself asking whether each point does or does not lie within any polygons. And for each point that does, you might then want to know which polygon it lies within. These kinds of containment questions fall in the domain of what are often referred to as point-in-polygon operations.