The geographic visualization of data makes up one of the major branches of the Digital Humanities toolkit. There are a plethora of tools that can visualize geographic information from full-scale GIS applications such as ArcGIS and QGIS to web-based tools like Google maps to any number of programing languages. There are advantages and disadvantages to these different types of tools. Using a command-line interface has a steep learning curve, but it has the benefit of enabling approaches to analysis and visualization that are customizable, transparent, and reproducible.^{1} My own interest in coding and R began with my desire to dip my toes into geographic information systems (GIS) and create maps of an early modern correspondence network. The goal of this post is to introduce the basic landscape of working with spatial data in R from the perspective of a non-specialist. Since the early 2000s, an active community of R developers has built a wide variety of packages to enable R to interface with geographic data. The extent of the geographic capabilities of R is readily apparent from the many packages listed in the CRAN task view for spatial data.^{2}

In my previous post on geocoding with R I showed the use of the `ggmap`

package to geocode data and create maps using the `ggplot2`

system. This post will build off of the location data obtained there to introduce the two main R packages that have standardized the use of spatial data in R. The`sp`

and `sf`

packages use different methodologies for integrating spatial data into R. The `sp`

package introduced a coherent set of classes and methods for handling spatial data in 2005.^{3} The package remains the backbone of many packages that provide GIS capabilities in R. The `sf`

package implements the simple features open standard for the representation of geographic vector data in R. The package first appeared on CRAN at the end of 2016 and is under very active development. The `sf`

package is meant to supersede `sp`

, implementing ways to store spatial data in R that integrate with the tidyverse workflow of the packages developed by Hadley Wickham and others.

There are a number of good resources on working with spatial data in R. The best sources for information about the `sp`

and `sf`

packages that I have found are Roger Bivand, Edzer Pebesma, and Virgilio Gómez-Rubio, *Applied Spatial Data Analysis with R* (2013) and the working book Robin Lovelace, Jakub Nowosad, Jannes Muenchow, *Geocomputation with R*, which concentrate on `sp`

and `sf`

respectively. The vignettes for `sf`

are also very helpful. The perspective that I adopt in this post is slightly different from these resources. In addition to more explicitly comparing `sp`

and `sf`

, this post approaches the two packages from the starting point of working with geocoded data with longitude and latitude values that must be transformed into spatial data. It takes the point of view of someone getting into GIS and does not assume that you are working with data that is already in a spatial format. In other words, this post provides information that I wish I knew as I learned to work with spatial data in R. Therefore, I begin the post with a general overview of spatial data and how `sp`

and `sf`

implement the representation of spatial data in R. The second half of the post uses an example of mapping the locations of letters sent to a Dutch merchant in 1585 to show how to create, work with, and plot `sp`

and `sf`

objects. I highlight the differences between the two packages and ultimately discuss some reasons why the R spatial community is moving towards the use of the `sf`

package.