R Packages for Spatial Analysis

Caitlin Dempsey


The R programming language is a dynamic tool that offers powerful statistical and data analysis capabilities.

In recent years, spatial data analysis and GIS applications have become increasingly popular, and R, with its comprehensive libraries and packages, has naturally become a preferred tool for many data scientists and GIS professionals.

This article takes a brief look some of the spatial packages in R that are available.

Caliper R package

The caliperR package serves as a bridge between Caliper software and an R programming environment. It provides access to all Geographical Information Systems Development Kit (GISDK) macros and functions. Using Component Object Model (COM) technology, it facilitates the transfer of data and results between the Caliper platform and R. For example, a ‘dataview’ in Maptitude can be seamlessly converted into a ‘data.frame’ in R.

Free weekly newsletter

Fill out your e-mail address to receive our newsletter!


At the core of spatial analysis in R is the rgdal package, which provides bindings to the Geospatial Data Abstraction Library (GDAL) and access to projection and transformation operations from the PROJ.4 library.

The rgdal package enables the reading and writing of a wide range of spatial data formats, both raster and vector. It also allows for coordinate reference system management, crucial for spatial operations such as overlay, intersection, and distance calculations.


The sp package allows handling and storage of spatial data. It defines classes for points, lines, polygons, and grids, alongside those for spatial data that combine these shapes with attributes.

Other spatial packages in R, including rgdal, are built upon these core spatial classes, and many functions in these packages return objects of the types defined in sp.


While the rgdal package provides access to spatial data, rgeos offers functions for spatial data manipulation and analysis based on the Geometry Engine – Open Source (GEOS) library. It performs geometric operations on spatial data types such as intersection, union, difference, and distance calculations. It’s crucial for geometric manipulations and topological relationships between geometries.


The raster package provides classes and functions to create, manipulate, visualize, and analyze raster data. It supports large datasets by processing them in chunks and only loading a small section into memory at a time.

Additionally, the package includes functions for spatial overlay, map algebra, and spatial modeling, making it an essential tool for GIS operations.


The sf package (short for “Simple Features”) is an addition that provides a simpler, more user-friendly approach to spatial data in R. It utilizes simple feature access for spatial vector data and provides a more straightforward and efficient interface than sp.

The sf package directly interfaces with GDAL, making spatial operations like subsetting, aggregating, and joining more intuitive.


The tmap package is a powerful tool for creating static and interactive thematic maps. It integrates seamlessly with the sf package and allows users to create publication-ready maps using simple syntax. tmap is useful for creating choropleth maps, bubble maps, or multi-layered maps.


The leaflet package brings the power of the Leaflet JavaScript library to R, offering interactive maps that can be embedded into web applications. It allows the overlay of spatial data on various web-based map providers such as OpenStreetMap, Stamen, and Mapbox.


The rasterVis package augments the visualization capabilities of the raster package. It utilizes the lattice package to create elegant and complex plots of raster data. From level plots and contour plots to 3D visualizations of terrain, rasterVis helps users to create a variety of plots to explore raster data thoroughly.


The maptools package is another foundational spatial package for R that offers a set of tools for manipulating and reading geographic data, in particular, the spatial data types of the sp package. It provides utility functions for topology operations such as simplifying, shifting, and rotating spatial objects.


For geostatistical analysis, the gstat package is a comprehensive resource. It offers various methods to estimate variograms and perform spatial interpolation, including kriging and inverse distance weighting. gstat supports point, gridded, and polygon data, making it a versatile tool for modeling spatial structures.


The spatstat package specializes in the analysis of spatial point patterns. It offers a wide range of methods for exploring and modeling point pattern data, from simple exploratory tools to advanced model-fitting techniques. spatstat is unique in its ability to handle irregular observation windows and spatial covariates.


The stars package (“spatiotemporal arrays, raster, and vector data cube”) is a more recent addition to R’s spatial data arsenal. It extends the work done by sf to include support for raster and timeseries data in a tidyverse-friendly format.

With stars, users can perform operations like subsetting and aggregating across multiple dimensions simultaneously.


The geosphere package is used for calculations related to spherical geometry. It is especially useful for the analysis of geographical coordinates. It includes functions to calculate distances, directions, areas of polygons, and more. It’s also able to calculate shortest paths or great circles and can handle date-line crossing.


The RgoogleMaps package allows for the easy use of Google Maps API in R. It provides an interface between R and Google Maps, enabling users to download static maps from Google Maps and use them as R plots.

With the help of other spatial packages, users can overlay spatial data on these maps to create informative visualizations.

Lists of popular spatial analysis R packages

Zev Ross has posted an expansive list of R packages being used for spatial analysis.  His list is the result of an information survey on Twitter where he asked users to let him know which R spatial packages were their favorites.  

Ross heard back from 27 people who supplied information about 45 different R spatial packages.  Of those replies, sf (Simple Features for R) was the most suggested with 16 replies.  As its name implies, sf is a package that provides simple features access for R.

Ross details out the rest of the results of his informational survey, listing the popularity of packages by replies.  He also details out the popularity based on monthly downloads for spatial packages listed on the CRAN Task View: Analysis of Spatial Data.

Visit the list: (Unscientific) list of popular R packages for spatial analysis

The Urban Demographics blog also has a smaller list of spatial analysis packages for R that lists and describes a few additional packages not included on Ross’s list such as RgeoProfile, rayshader, dodgr, and rmapshaper.

The r-spatial site also provides links to spatial packages found on CRAN under various views as well as a short list of R packages under development on GitHub not listed on CRAN.  Visit the r-spatial projects page to see the links.

Many spatial packages available for R

These are just some of the many spatial packages available for R. They provide a wealth of tools for the manipulation, analysis, and visualization of spatial data, from basic operations to advanced spatial modeling and interactive map generation.

If you’re interested in spatial analysis or GIS, these R packages provide an excellent starting point. As spatial data continues to grow in importance across industries, the knowledge and application of these tools will become increasingly valuable.

This article was originally written on May 2, 2019 and has since been updated.

See Also

Photo of author
About the author
Caitlin Dempsey
Caitlin Dempsey is the editor of Geography Realm and holds a master's degree in Geography from UCLA as well as a Master of Library and Information Science (MLIS) from SJSU.