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

# 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

# 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

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

# Map of Australia
oz( states=TRUE, col="#69b3a2")

Related chart types

Hexbin map
Bubble map

❤️ 10 best R tricks ❤️

👋 After crafting hundreds of R charts over 12 years, I've distilled my top 10 tips and tricks. Receive them via email! One insight per day for the next 10 days! 🔥