Movatterモバイル変換


[0]ホーム

URL:


CRAN Task View: Analysis of Spatial Data

Maintainer:Roger Bivand, Jakub Nowosad, Krzysztof Dyba
Contact:Roger.Bivand at nhh.no, nowosad.jakub at gmail.com, krzysztof.dyba at amu.edu.pl
Version:2025-11-11
URL:https://CRAN.R-project.org/view=Spatial
Source:https://github.com/cran-task-views/Spatial/
Contributions:Suggestions and improvements for this task view are very welcome and can be made through issues or pull requests on GitHub or via e-mail to the maintainer address. For further details see theContributing guide.
Citation:Roger Bivand, Jakub Nowosad, Krzysztof Dyba (2025). CRAN Task View: Analysis of Spatial Data. Version 2025-11-11. URL https://CRAN.R-project.org/view=Spatial.
Installation:The packages from this task view can be installed automatically using thectv package. For example,ctv::install.views("Spatial", coreOnly = TRUE) installs all the core packages orctv::update.views("Spatial") installs all packages that are not yet installed and up-to-date. See theCRAN Task View Initiative for more details.

Base R includes many functions that can be used for reading, visualising, and analysing spatial data. The focus in this view is on “geographical” spatial data, where observations can be identified with geographical locations, and where additional information about these locations may be retrieved if the location is recorded with care.

Base R functions are complemented by contributed packages provided as source packages, and as ready-to-run binary packages for Windows and macOS (Intel 64-bit and Apple Silicon arm64 architectures). Information about source installs of packages using software external to R may be found at the end of this page. This task view covers the current status of contributed packages available from CRAN.

The contributed packages address two broad areas: moving spatial data into and out of R including coordinate transformation, and analysing spatial data in R. Because the contributed packages constitute an evolving ecosystem, there are several points of entry for users looking for help and information. Two informal organisations curate websites:r-spatial with a hyphen, andrspatial without. R-spatial is more generally geo-informatics based, grew from the legacysp package and is now clearly aligned with the modernsf andstars packages. Rspatial has grown from theraster package, now moving towards the modernterra package. It is also worth noting the wealth of online book projects, which may be helpful for users seeking an introduction, includingGeocomputation with R.

Specific questions or issues may be raised wherepackageDescription(<pkg>)$BugReports returns an URL for bug reports or issues (where<pkg> is the name of the package as a string), or directly with package maintainers by email. Use may also be made of theR-SIG-Geo mailing-list after subscription, or ofStack Overflow with appropriate tags, or ofStack Exchange. Using the#rspatial tag onMastodon may also be worth trying, or browsing traffic using that tag (among others); BlueSky currently is emerging.

The packages in this view can be roughly structured into the following topics. If you think that some package is missing from the list, please e-mail the maintainer or submit an issue or pull request in the GitHub repository linked above.

Table of contents

Classes for spatial data and metadata

Many of the packages for handling and analysing spatial data use shared classes to reduce duplication of effort. Up until 2016, thesp package provided shared classes for spatial vector and raster data, but the representations used preceded more modern and efficient international standards for spatial vector data. From the release ofsf, these modern vector representations are to be preferred. For spatial raster data, the representations proposed instars andterra suit overlapping but slightly different requirements. Conversion between objects of classes defined bysf,stars,terra and the legacysp packages are available, and are described inConversions between different spatial classes in R.

Complementary initiatives are ongoing to support better handling of geographic metadata in R.

Spatial data - general

Raster data

Geographic metadata

Reading and writing spatial data

Spatial data is most often represented by one of two data models, vector or raster, and both models have many of their own file formats.GDAL (Geospatial Data Abstraction Library) is a (non-R) library that provides a unified way to read and write hundreds of spatial data formats. Formats supported by GDAL include both OGC standard data formats (e.g., GeoPackage) and proprietary formats (e.g., ESRI Shapefile). GDAL is used by a large number of GIS software and also many R packages, such assf,terra, andvapour, and thegdalraster package explicitly implements the GDALRaster andVector Data Models. This allows us to read and write spatial data in R from and to various spatial file formats. Important note: CRAN offers binary versions of packagesgdalraster,sf,terra, andvapour for Windows and macOS, that contain specific GDAL version with a subset of possible data source drivers. If other drivers are needed, you need to either use other conversion utilities or install these packages from the source against a version of GDAL with the required drivers.

In the past,rgdal andraster (throughrgdal) were recommended for reading and writing of spatial data in R. However, due tothe retirement of rgdal on 16 October 2023 new projects should not use it, and existing projects should implement migration to the packages mentioned in the previous paragraph. In addition,rgeos andmaptools were archived at the same time. Further details and links may be found inproject reports on the evolution project. From October 2023,sp only uses methods fromsf in place of those fromrgdal for projection and access to the underlying definitions of coordinate reference systems.

Reading and writing spatial data - data formats

Other packages provide facilities to read and write spatial data, dealing with open standard formats or proprietary formats.

Open formats

Proprietary Data Formats

Reading and writing spatial data - GIS software connectors

Specific geospatial data sources of interest

Interfaces to Spatial Web-Services

Some R packages focused on providing interfaces to web-services and web tools in support of spatial data management. Here follows a first tentative (non-exhaustive) list:

Handling spatial data

Data cleaning

Data processing - general

Data processing - specific

Remote sensing

Spatial sampling

Visualizing spatial data

Base visualization packages

Thematic cartography packages

Packages based on web-mapping frameworks

Building cartograms

Analyzing spatial data

The division of spatial statistics into three partly overlapping areas: point pattern analysis, geostatistics and the analysis of areal/lattice data, is widely accepted. However, areal data analysis can be split into disease mapping and spatial regression (also partly overlapping). In addition, ecological analyses often approach spatial data in particular ways, giving rise to a specific topical cluster of packages. Moreover, machine learning for spatial data is a growing area of interest, and there are packages that provide tools for this. All of these approaches to analysing spatial data treat the spatial relationships between observations as a way of exploring and making use of important sources of information about the observations over and above what is known when assuming that they are independent of each other.

Point pattern analysis

Point pattern analysis examines the distance relationships between observed points, where the set of observations is expected to encompass all such entities in the study area.

Geostatistics

Geostatistics uses a model fitted using the distances between observations to interpolate values observed at point to unobserved points

Disease mapping and areal data analysis

Both point pattern analysis and geostatistics enter into disease mapping, which is concerned with representing public health information over space and time in a communicative and responsible way. Estimation is important to present calculated rates that are comparable both in terms of levels and uncertainty.

Spatial regression

Many packages providing functions for fitting spatial regression models have already been given as they are used in disease mapping. In this subsection, more attention is given to the subset of methods used in spatial econometrics, and so complements general econometric methods covered in theEconometrics Task View.

Ecological analysis

There are many packages for analysing ecological and environmental data. They include:

TheEnvironmetrics Task View contains a much more complete survey of relevant functions and packages.

Machine learning of spatial data

Machine learning of spatial data requires specialized methods to account for spatial dependencies like spatial autocorrelation – where nearby observations tend to be similar. Ignoring these dependencies during model training and evaluation risks information leakage. For example, randomly splitting spatial data into training and testing subsets, without considering spatial autocorrelation, can result in test samples being spatially close to training samples. This violates the assumption of independence between training and test sets and can lead to inflated performance metrics and poor model generalization.

To address this, various approaches and methods to account for spatial dependencies and relationships when building models were developed. In general, machine learning of spatial data can be performed through one of the existing machine learning frameworks in R, such ascaret,mlr3, andtidymodels or through specialized spatial machine learning packages.

Installing packages linking to PROJ, GDAL or GEOS

Installation of packages likegdalraster,sf andterra which use external software libraries such as PROJ, GDAL or GEOS requires care. For most users on platforms such as Windows or macOS who are not themselves package developers, it is always better to avoid what are known as source installs, because CRAN binary packages include all of the external software required. BecausegetOption("pkgType") on these platforms is usually"both", you may be asked to choose to install a source package if it is more recent than the latest binary.

Please do not be tempted to choose a source install forsf orterra or similar; the binary package will be generated within a day or two. To avoid being asked, you may see from?options under options provided by the utils package that the default behaviour of your installation of R may be controlled by setting optionsinstall.packages.check.source andinstall.packages.compile.from.source, or by setting environment variableR_COMPILE_AND_INSTALL_PACKAGES, see also thishelpful comment.

If you are a developer using Windows or macOS or installing fromgithub, the same static-linked binary external software libraries, header files, etc. as those used in building CRAN binary packages are available from: Windows 4.0 and 4.1downloaded on-the-fly, Windows 4.2RTools42, Windows 4.3RTools43, and macOSboth architectures. These external software libraries have been built using the same compile and link settings as R itself, so avoid the risk of possible errors caused by mismatched binaries. The current versions may be updated between R releases, in order to give access to more recent versions of GDAL, GEOS or PROJ.

If you are a user (or developer) on systems wheregetOption("pkgType") is"source", you will need to ensure that the external software is available when installing source packages. Advice for some such systems may be foundhere.The most common reason for failure is having multiple versions of external software installed on your platform.

CRAN packages

Core:classInt,DCluster,deldir,dggridR,geoR,gstat,sf,spatialreg,spatstat,spdep,stars,terra.
Regular:ade4,adehabitatHR,adehabitatHS,adehabitatLT,adehabitatMA,ads,areal,autoFRK,automap,blockCV,CARBayes,caret,cartogram,CAST,CDSE,centerline,CFtime,chilemapas,constrainedKriging,cshapes,dbmss,DClusterm,dismo,divseg,duckspatial,ecespa,elevatr,exactextractr,ExceedanceTools,fields,FlexScan,FRK,gdalcubes,gdalraster,gdalUtilities,gdistance,gdverse,gear,geobr,geodata,geogrid,geojson,geojsonio,GEOmap,geomapdata,geometa,geonames,geonapi,georob,geos,geosapi,geosphere,geospt,geostan,ggmap,ggplot2,ggspatial,giscoR,gmt,gpboost,GWmodel,gwrr,hglm,intamap,interp,ipdw,landsat,landscapemetrics,LatticeKrig,leaflet,libgeos,lidR,link2GI,lwgeom,magclass,mapdata,mapdeck,mapedit,mapme.biodiversity,mapmisc,mapproj,maps,mapsf,mapSpain,mapview,marmap,MBA,mbg,MBHdesign,meteo,mgcv,micromap,mlr3,mlr3spatial,mlr3spatiotempcv,ModelMap,modisfast,MODISTools,ncdf4,ncf,ngspatial,nlme,OasisR,openeo,OpenStreetMap,osmapiR,osmdata,osmextract,OTBsegm,ows4R,pastecs,PBSmapping,PBSmodelling,PReMiuM,ProbitSpatial,qgisprocess,qualmap,rakeR,ramps,RandomForestsGLS,raster,rasterVis,rcartocolor,RColorBrewer,RCzechia,recmap,regress,rgbif,rgee,rgeoda,RgoogleMaps,rgrass,rgugik,rmapshaper,rnaturalearth,RNetCDF,rpostgis,RPostgreSQL,RPyGeo,RSAGA,Rsagacmd,rsample,rsat,rsi,rstac,RStoolbox,rtop,s2,sfhotspot,sgeostat,shapefiles,siplab,sits,smacpod,smerc,sms,sp,spacetime,spaMM,sparr,spatgraphs,spaths,spatial,spatialCovariance,SpatialEpi,SpatialExtremes,SpatialPosition,spatialprobit,spatialRF,spatialsample,SpatialTools,spBayes,spBayesSurv,Spbsampling,sperrorest,sphet,spind,splancs,splm,spmodel,spmoran,spselect,spStack,spsur,spsurvey,spTimer,sptotal,SSN2,starma,statebins,terrainr,tgp,tidycensus,tidymodels,tigris,tmap,trip,tripEstimation,vapour,vardiag,varycoef,vegan,viridis,waywiser,whitebox,wk,yardstick.
Archived:forestdata,geouy,lctools.

Related links

Other resources


[8]ページ先頭

©2009-2025 Movatter.jp