The Maps, Mapdata and Oz packages to get most common boundaries



The maps, mapdata and oz packages provide the boundaries of the most common world regions like the US, Europe, New Zealand and more. This post describes how to use them to avoid struggling finding input data.

Background map section About Maps

maps package


The maps package is the best source of geospatial data in R.

The whole list of offered data is available typing: help(package='maps').

It includes:

  • World: world, world.cities, lakes
  • US: states, county, state, usa
  • France: france
  • Italy: italy
  • New zealand: nz

The code below shows how to use one of this geospatial object.

# Load library
library(maps)

# Check all available geospatial objects:
# help(package='maps')

# Map of the world:
map('world',col="grey", fill=TRUE, bg="white", lwd=0.05, mar=rep(0,4),border=0, ylim=c(-80,80) )

mapdata package


The mapdata package extends the maps package with more geospatial datasets:

  • china
  • japan
  • Other world versions like pacific Centric (world2Hires)

See complete list with help(package='mapdata')

# Load library
library(mapdata)

# Check all available geospatial objects:
# help(package='mapdata')

# Map of Japan:
map('japan',col="black", lwd=1, mar=rep(0,4) )

oz package


The oz package provides several geospatial object concerning Australia.

Plot the general country using the oz() function, or states using nsw(), qld() and so on..

Type help(package='oz') for documentation.

# Load library
library(oz)

# Check all available geospatial objects:
# help(package='oz')

# Map of Australia
par(mar=rep(0,4))
oz( states=TRUE, col="#69b3a2")

Related chart types


Map
Choropleth
Hexbin map
Cartogram
Connection
Bubble map



Contact

This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message on Twitter, or send an email pasting yan.holtz.data with gmail.com.

Github Twitter