3.2 Raster data

Raster data are commonly used to represent continuous phenomenon that can be observed everywhere, but without natural boundaries (but with artificial boundaries defined by the user). A raster consists of a grid of equally sized cells (or pixels) that all have a values (or a missing value) for one single variable.

Unlike vector data, the geometry of raster data is not explicitly stored as coordinates. Rather it is implicitly set by setting the spatial extent and the number of rows and columns of a regular grid. From this spatial information, the size of the raster cells (spatial resolution) can be computed. Working with raster data will therefore be more efficient than working with polygons data.

Raster can be used to represent a very broad range of data: continuous (temperature values), discrete (habitat classes) or even binary (species occurrence) variables.

#R>  Please note that rgdal will be retired during 2023,
#R>  plan transition to sf/stars/terra functions using GDAL and PROJ
#R>  at your earliest convenience.
#R>  See https://r-spatial.org/r/2022/04/12/evolution.html and https://github.com/r-spatial/evolution
#R>  rgdal: version: 1.6-4, (SVN revision 1196)
#R>  Geospatial Data Abstraction Library extensions to R successfully loaded
#R>  Loaded GDAL runtime: GDAL 3.4.1, released 2021/12/27
#R>  Path to GDAL shared files: /usr/share/gdal
#R>  GDAL binary built with GEOS: TRUE 
#R>  Loaded PROJ runtime: Rel. 8.2.1, January 1st, 2022, [PJ_VERSION: 821]
#R>  Path to PROJ shared files: /home/runner/.local/share/proj:/usr/share/proj
#R>  PROJ CDN enabled: FALSE
#R>  Linking to sp version:1.6-0
#R>  To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#R>  use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.


Several file formats exist to store raster data. The most commons are: GeoTIFF, NetCDF, grd and ascii formats. Even the package rgdal can be used to import/export raster data, we will prefer the package raster.