Simple features

If you want to start drawing maps in R, the best place to begin is to familiarize yourself with the Simple Features (sf) data format. This is an open standard developed by the Open Geospatial Consortium, meant to represent geographical vector data.

The sf package in R is a great implementation of this, and allows you to work with the sf data as regular data frames. I.e. you can do typical data operations, like filters, grouped calculations, join with other datasets, etc. There has also been functionality implemented for ggplot2, so you can draw maps using geom_sf. All of the good stuff.


Plotting maps with ggplot2

I want to draw maps of Greenland. The National Survey of Greenland (ASIAQ) has an online map, which is useful for downloading geolocations of cities and borders. It does not have a hi-res shapefile of the island though, so I’ve opted to use the sf data found in the rnaturalearth package.


# Gets world data in sf format
world_sf <- ne_countries(returnclass = "sf")

# Draws a map
world_sf %>% 
  ggplot() +