R Resources‎ > ‎

Creating a simple map

I was excited to figure out how to make nice, simple maps to show my study sites in R, so I will share it here. This uses a package called 'maps'. Here's a link to the documentation.

library(maps) #We use the package called 'maps'
#first create a set of coordinates for the points you want to plot.

#We then generate a map of two regions (Alaska and Canada) from the database called 'world'. There are a couple of other databases for mainland US and other world regions. I'm using the options here to cut off the Eastern part of the map (using xlim=...) and filling in the map with a light gray color.

map(database="world",regions=c("USA:alaska","canada"),xlim=c(-170,-90),col=gray(0.9), fill=TRUE)
#we now simply add 'points' to this map using the coordinates. Notice that longitude is the first element because measured on the xaxis, followed by the latitude. The rest are standard options for points(). Finally, we add dotted gray grid lines
points(coords$long, coords$lat, pch="*",cex=3,col="red")

... and there it is!