GIS, Cartographic and Spatial Analysis Tools: R / Rstudio

This guide provides an overview of geographic software, libraries and tools supported by or recommended by RDS staff.

R is an open source statistical programming language and platform that is widely used in statistical analysis, data science and data visualization.  Although R was not originally designed to work with spatial data formats, it has long had a strong geospatial developer community and can be used as a powerful GIS platform with the addition of external packages.  R is particularly powerful for spatial statistical analysis and quantitative researchers in particular may find R more useful than GIS desktop applications. 

R is free and and cross-platform and can be downloaded from The Comprehensive R Archive Network (CRAN).

Most users work with R in an IDE.  We recommend RStudio, which has a free desktop version that you can download here.

Useful R Packages

You will surely need to install at least a few external packages to work with geospatial data.  We will list here a number of the most useful packages, but there are many others.  A better idea may be to see the excellent CRAN Task View: Analysis of Spatial Data for a longer and more detailed list of geospatial packages

Basic data manipulation

simple features for R (sf) is the most popular package for encoding of spatial data.  Functionally replaces the sp package (which is still supported). 

raster for working with raster (gridded) data. 

rgdal provides bindings to the Geospatial Data Abstraction Library 

rgeos for manipulation and querying of spatial geometries using the GEOS geometry engine

maptools is a popular set of tools for manipulating geographic data

shapefiles has functions for reading and writing ESRI Shapefiles

ncdf4 for working with netCDF files

Cartography and data visualization

ggplot2 for crating plots and maps using the "grammar of graphics"

RColorBrewer for using color schemes created by Cynthia Brewer

viridis is another popular source for color palettes

tmap for thematic mapping using "grammar of graphics" syntax

leaflet for the creation of interactive web maps using Leaflet

mapview for creation of interactive spatial visualizations with pop-up windows for attribute data

cartography for creation of cartographic representations with typical map elements

choroplethr simplifies the production of choropleth maps

ggmap web mapping with Google Maps of OpenStreetMap

Spatial Statistics

spatial package for kriging and point pattern analysis

spatstat package for point pattern analysis

gstat package for modelling, prediction and simulation of geostatistical data in one, two or three dimensions

spdep for creating spatial weights matrices

Data Sources

tigris provides cartographic files from the US Census 

tidycensus access to the US Census APIs for the American Community Survey and then Decennial Census

rnaturalearth for access to Natural Earth data (basemap)

RSocrata for access to Socrata Open Data portals (including NYC Open Data