Most R packages are developed and maintained by the community, which shows how open-source software development can facilitate innovation, reproducibility, and reuse of code. There are three major online platforms to host R packages and make them accessible to potential users: CRAN, GitHub, and Bioconductor. The last one focuses on tools for the analysis of genomic data; therefore, in this review we focus on only the former two.
CRAN (the Comprehensive R Archive Network) provides large visibility to the community, ease of installation, and a technical quality standard, including checks for common problems on all major operating systems . GitHub hosts source code under version control, and allows users to install packages with one line of code using the remotes  package. Additionally, hosting a package on GitHub provides many useful features to collaborate and communicate between developers and users , or integrated unit testing (i.e., testing if functions return an expected value).
The guaranteed technical quality standard of CRAN requires more initial work for developers compared to GitHub. At the same time, it ensures for users that the package can be installed on their machine. Additionally, the technical quality standard of CRAN also facilitates reproducibility and reuse of code, as shown by many reverse dependencies of R packages, i.e., package x requires and uses code from package y. CRAN also provides archived versions of outdated or orphaned packages, thus ensuring long-term availability and reproducibility of code. That being said, most R packages can be found on both platforms, and many developers use GitHub for regular development and CRAN to publish stable releases of the packages. Furthermore, online communities like rOpenSci also provide a peer-review process for code quality. It is important to mention that while the package environment has many advantages, its highly dynamic characteristic with constant updates by the community might also be a threat to reproducibility since backward compatibility is not always ensured. Packages that deal with such issue include groundhog , packrat , or renv . These packages facilitate reproducibility to a high degree by preserving the project environment, including specific package versions used for the analysis. For more information about R package development in general, see .
Spatial Data Representations
While base R has several built-in data structures, including vectors, matrices, data frames, and lists, yet it has no internal support for reading, processing, or visualizing spatial data. However, as discussed previously, one strength and core idea of the R programming language are its expandability by packages. Because there is a substantial interest in spatial data analysis, support for spatial data is now provided by many R packages ([22••], Table 1). Most spatial data belong to one of two data models, namely spatial raster and spatial vector model, and both data models have several implementations in the R language. Importantly, main R packages for spatial data use the external GDAL  and PROJ  libraries, which allow for reading and writing of hundreds of spatial data formats, and for coordinates transformation. Additionally, R allows for conversion between data models and specific implementations, which can be useful if given methods only exist for a particular data model or implementation.
In the raster data model, surfaces are divided into cells, where each cell stores a numeric value. The values could represent discrete phenomena, such as a class number of a land cover category, or continuous phenomena, such as elevation values. Currently, the most prominent package allowing for raster data representation is raster . A raster successor, terra, aimed at the simpler interface and improved performance is being developed , however, it could take several years for this package to be adopted by other developers and users. Alternatively, the stars package can be used to read and process raster data focusing on spatial-temporal data cubes . Additionally, there are packages that improve some basic raster operations in terms of computational performance or compatibility between raster and vector operations, such as fasterize , rasterDT , or exactextractr .
The vector data model consists of two main elements i) geometries (such as points, lines, polygons) and ii) attributes, where each geometry is connected to a row in the attribute table. In many cases, this data model allows a more realistic representation of landscape features, however, with higher computational cost [22••]. The sp package was the standard for vector data representation for more than ten years [44, 45]. As of 2020, more than 500 R packages directly depend on or import sp. However, sp is not actively developed anymore, and its recommended successor is the sf package . Besides many advantages and strengths of the sf package in terms of spatial data handling, it also integrates into the widely used tidyverse packages . The tidyverse is a collection of R packages developed for almost all major tasks of any data analysis project. Because all tidyverse packages follow the same philosophy how to structure data, one strength of the tidyverse is its high consistency of usage across its packages . sf builds on the idea of “simple features,” a standard used to describe spatial geometries using points, lines (two connected points) and polygons (several connected points), and attributes connected to these geometries .
Spatial Data Download
Nowadays, spatial data at various scales is available from many online-accessible sources. A lot of this data are publicly available, either as a direct download or through an API connection, and several packages can use this to download the spatial data directly into a R session. Since publicly available data is becoming more prominent, so are R packages to access them. Packages include rnaturalearth  to access the Natural Earth database to download region and country data, the elevatr package to access raster elevation data , the rgbif package to access the Global Biodiversity Information Facility (GBIF) portal , the BIEN package  to access the Botanical Information and Ecology Network Database, the marmap to download bathymetry data from the ETOPO1 database , or the FedData package  to access the National Land Cover Database (NLCD) data for the USA. Furthermore, the getlandsat package  allows users to download Landsat 8 satellite data, the MODIS package  to download MODIS products, and sen2r  to download Sentinel-2 optical images. Also, the getData() function from the raster package allows users to download climatic and bioclimatic data from WorldClim v1.4. Additionally, the rgee package  gives access to an extensive catalog of data from Google Earth Engine, including climate data, land cover maps, and satellite imagery.
Spatial Data Processing
Coordinate reference systems (CRS) describe how spatial data are projected from the earth’s three-dimensional surface to a two-dimensional surface as required for spatial analysis or creating maps [22••, 27]. This is also referred to as spatial projection and is often the first barrier in spatial data analysis. It is not only required to have all of the used data in the same projection, but also to select a proper CRS. This is of importance because the projection into a two-dimensional surface unavoidably leads to distortion, and different CRS are optimized for different properties, regions of the world, and scales [22••, 45]. Coordinates in spatial data represent one of many coordinate reference systems. Two main groups of CRS, namely geographical and projected, exist, with each having many members. Using geographical CRS, positions are specified by latitude and longitude coordinates in degrees. However, most landscape ecology studies should utilize projected CRSs, which use some measurement units (e.g., meters). The selection of projected CRS should be based on the property of spatial data that needs to be kept intact (e.g., no distortion of areas, shapes, distances, or angles) and be appropriate for a given study area. A common way to refer to different CRS is to use codes developed by the European Petrol Survey Group (EPSG). Tools to find an appropriate CRS for a certain region can be found at https://spatialreference.org, https://epsg.org, or http://epsg.io. All packages from “Spatial Data Representations” have interfaces for coordinates transformations, allowing unification of spatial projections when the used data have different CRS.
Until 2020, spatial R objects stored information about their CRS using Proj4 string representations, and these strings could also be used for CRS transformations. However, the major changes in upstream software, namely PROJ6 and GDAL3, limited the capabilities of the Proj4 strings and switched to use a new representation called WKT2-2019 for storing the CRS. Thus, spatial objects saved with degraded Proj4 string representation to R file formats could be incorrectly read, and special attention should be given to check their correctness. Proj4 string representation is also not recommended to set or transform CRS and instead the previously introduced EPSG codes should be used. A more detailed explanation of the recent CRS changes can be found in [28••].
Another common spatial data processing task is required when the available data extends over a larger area than the study region. In this case, the pre-processing of spatial data should include vector clipping or raster cropping. Related to that, masking certain areas of the study region using spatial filters (e.g., water bodies, urban areas) can be required. Packages from “Spatial Data Representations” also allow for these operations. Additionally, they offer many other operations, such as merging or joining spatial data, extracting values from one dataset into another, raster resolution changes, or vector data simplifications. A comprehensive collection of methods to aggregate raster values to a coarser resolution can also be found in the grainchanger package . Furthermore, landscapetools is a collection of various utility functions for the raster data model .
Finally, there are several tools for landscape ecology implemented in GIS software, such as r.li or r.pi for GRASS GIS [31, 60, 61], terrain analysis methods in SAGA GIS , or morphological operations for Google Earth Engine. It is possible to control several GIS software directly from R using dedicated packages, such as rgrass7  for GRASS GIS, RSAGA  for SAGA GIS, and rgee  for Google Earth Engine. Direct access to these GIS software within R allows to create reproducible and sharable R scripts, even if functionality is currently not available in R.
Creating maps is essential when working with spatial data. Maps play an important role in checking the spatial and value-related quality of data, data exploration, and finally communicating results. R allows two major types of maps. Firstly, static maps in which the developer has full control over the presentation of the map and secondly, interactive maps in which the user can modify the map by, e.g., changing the displayed values. All packages listed in “Spatial Data Representations” have build-in methods for plotting spatial data using the generic plot() function (Fig. 2a). However, the generic functions are focused on quick visual inspection of the data (Fig. 2a), rather than creating complete maps as they do not directly support additional map elements (e.g., scale bar, north arrow) nor small multiples maps.
Quantify Landscape Characteristics
One of the most fundamental steps of landscape ecology analyses is to describe and quantify landscape characteristics [2, 73]. For discrete land cover classes, the composition (number and abundance) and configuration (spatial arrangement) of the landscape are often described using landscape metrics [74,75,76,77•]. These metrics allow the comparison of different landscapes, quantification of temporal and spatial landscape changes and investigation of interactions between landscape characteristics and ecological processes .
The introduction of FRAGSTATS in 1995 heavily facilitated the use of landscape metrics software [77•–79] and the landscapemetrics package  allows to calculate the most widely used landscape metrics within the R environment.
More recently, surface metrics were suggested as an alternative to landscape metrics for continuous raster data . The geodiv package  allows calculation of gradient surface metrics to facilitate continuous analysis of landscape features. Additionally, the belg package allows calculation of the Boltzmann entropy of a landscape gradient .
Most landscape metrics are represented by a single number depicting specific characteristics of a local landscape. Another possibility is to derive spatial signatures - a multi-value representation of landscape composition and configuration, such as a co-occurrence histogram . Spatial signatures calculated for many landscapes can be compared using one of a set of existing distance measures (e.g., Euclidian, Jensen-Shannon, Jaccard). This enables several types of spatial analysis on categorical raster data, such as searching for similar landscapes, detecting changes between landscape patterns, and spatial clustering of landscapes based on their composition and configuration. All of the spatial signatures methods mentioned above are implemented in the motif package .
Spatial statistics are complimentary to landscape metrics, and can be used to analyze patterns in continuous data (e.g., normalized difference vegetation index, disturbance intensity, topography). In landscape ecology, spatial statistics has three key uses: i) detecting and correcting for spatial autocorrelation; ii) quantifying and comparing landscape patterns; iii) interpolating data.
Point pattern analysis uses event-level data, such as locations of individuals, and links the spatial pattern to the ecological process. The spatstat package  contains functionality for point pattern analysis, including exploratory analysis; simulation of point process models; and modeling fitting, inference, and diagnostics. A comprehensive textbook covering both theoretical background as well as applied examples can be found here .
Distance-based methods allow for the detection and correction of spatial autocorrelation in data. It is key to do so as landscape data are highly spatially autocorrelated, and this non-independence can affect inferences from statistical modeling. The spdep package  has methods for quantifying multiple metrics of spatial autocorrelation and correcting these in a spatial autoregressive model. The rinla  and inlabru  packages also provide functionality for modeling of spatially structured data.
Finally, the spatial structure of continuous landscapes can be quantified and compared with geostatistical tools, such as variograms and correlograms. R packages geoR  and gstat  provide functionality for this type of analysis, as well as interpolation methods, known as (co-)kriging. Geostatistics also allows for spatial data simulations.
Species Distribution Modeling
Species distribution modeling (SDM) examines how landscape patterns (e.g., habitat suitability or resources availability) influence and determine the patterns of species’ distributions, mainly to infer ecological processes and predict future species’ distributions . Originated in the 1970s, SDM has experienced numerous methodological advancement, and a large body of literature exists today [92, 93]. Additionally, textbooks introducing basic concepts of SDM in R exist [26, 94].
Because the used modeling approaches are diverse [26, 95, 96], there is also a large number of R packages used for SDMs. Popular approaches and packages include generalized linear models using, e.g., the stats  package; generalized additive models using, e.g., the mgcv  or lme4  package; classification and regression trees (CART) using, e.g., the rpart , randomForest  or ranger  package or multivariate data analysis using, e.g., the ade4  or vegan  package. Also, packages specifically designed for SDM exist, including the dismo , sdm , ecospat , biomod2 , PresenceAbsence , or zoon  packages. Additionally, packages such as ENMeval  provide functionality for model tuning and evaluation.
Related to SDMs, there is a growing number of R packages to analyze data from tracked animals, to study their movement characteristics, space use, and interaction with other animals and the environment. These analyses often use results of landscape ecological analyses as predictor variables to explain variation in space use , behavioral states , or habitat selection . Widely used R packages include ctmm  and adehabitatHR  for home-range estimation, moveHMM  for the classification of behavioral states, and amt  for habitat selection. A recent and very comprehensive overview of R packages for the analysis of animal movement data is given by .
Connectivity is one of the core elements of landscape structure  and thus one of the core concepts of landscape ecology . Landscape connectivity describes how landscape characteristics facilitate or hinder the movement of species  or other aspects of mobility, such as dispersal, gene or nutrient flow . While structural connectivity focuses only on landscape characteristics (e.g., movement corridors, barriers), functional connectivity also includes behavior characteristics of the species such as habitat associations and dispersal distances [3, 120]. Given its broad concept, many different measures of connectivity exist . At the patch level, structural connectivity can be measured using nearest-neighbor distances or characterizations of the patch neighborhood (e.g., amount of suitable habitat) [3, 121]. Such measures are provided within the landscapemetrics package (see “Quantify Landscape Characteristics”). Furthermore, the lconnect package  and Makurhini package  provide several landscape connectivity metrics. Another way to describe connectivity is based on graph theory with the advantage that functional connectivity can also be included . In graph theory , landscapes are described by nodes (i.e., habitat patches) connected by and functional connections called links (or edges) . The grainscape package  provides a tool to model connectivity based on spatially explicit networks. More generally, the igraph package  provides functionality for graph theoretic analyses. Resistance surfaces and least-cost paths are other tools to model functional connectivity which include attributes of the matrix. The resistance surface describes the effects of facilitating or hindering the landscape’s characteristics for an organism moving within it . Least-cost paths can be calculated using the gdistance package . Absorbing Markov chains quantify landscape connectivity as the combination of movement and mortality based on the landscape characteristics , and is provided by the recently published samc package .
Landscape genetics investigates how characteristics of landscapes interact with gene flow, genetic drift, and selection . Such insights improve our understanding of metapopulation dynamics, speciation, species’ distributions, and conservation . By explicitly including landscape characteristics, landscape genetics provides a more detailed analysis than more abstract concepts (e.g., metapopulation genetics) . As a result of its interdisciplinarity, landscape genetics draws together methods from multiple fields, including landscape ecology, spatial statistics, geography, and population genetics .
Since describing connectivity between two locations is one of the fundamental steps of landscape genetics, all packages useful for connectivity (see “Connectivity”) are also important for landscape genetics. Further functionality for landscape genetics such as quantifying and analyzing population genetic structure, and hierarchical decomposition analysis can be found in the graphs4lg , PopGenReport [135, 136], HierDpart , or GeNetIt  packages.
Neutral Landscape Models
Neutral landscape models are used to create structured landscapes in the absence of specific ecological and landscape processes as null models against which hypotheses including specific ecological and landscape processes can be tested statistically [139, 140]. Because neutral landscape models are not based on ecological and landscape processes, many different generic algorithms to create landscapes can be found across several R packages. A comprehensive collection of algorithms to simulate neutral landscape models specifically designed for landscape ecology can be found in the NLMR package . Furthermore, the RandomFields package  allows to simulate Gaussian fields, which could be used as neutral landscape models.