
Mapping antipodes using the ggmap package

Peter Prevos |
617 words | 3 minutes
Share this content
When I was much younger, growing-up in the Netherlands I was fascinated by the conundrum of what happens when you drill a hole straight through the centre of the earth. I always believed that I would turn up in Australia. Well, I did end up in Australia, but not by drilling a hole. But is this really the case? This article is about mapping antipodes using the ggmap package of the R language.
The antipodes of any place on earth is the place that is diametrically opposite to it. A pair of antipodes are connected by a straight line running through the centre of the Earth. These points are as far away from each other as is possible on this planet. Two people are antipodes when they live on opposite sides of the globe.
The term antipodes was first coined by the ancient Greeks. Antipodes are people whose feet (πούς/pouch in Ancient Greek) are directly opposite each other. This concept was a direct consequence the Hellenistic understanding of geography, but the existence of such lands or peoples was often debated or outright denied.
How can we use coding in R to solve this conundrum?
Mapping antipodes with ggmap
We can roughly recreate the antipodean map on Wikipedia with the globe package. This package, written by Adrian Baddeley, plots 2D and 3D views of the earth. The package contains a data file with major coastlines that can be used to create a flipped map of the world. The ggplot2 package uses the globe to visualise maps.
The package contains a data file with major coastlines that can be used to create a flipped map of the world. To turn a spatial location into its antipode you subtract 180 degrees from the longitude and reverse the sign of the latitude, shown below.

library(ggplot2)
## Antipodean globe
world <- map_data("world")
anti_world <- world %>%
mutate(long = long - 180,
lat = - lat)
ggplot() +
geom_polygon(data = world, aes(long, lat, group = group), fill = "grey") +
geom_polygon(data = anti_world, aes(long, lat, group = group),
fill = "blue", alpha = 0.2) +
coord_map("ortho", orientation = c(0, 100, 00)) +
theme_void()
We can also use the ggmap package to visualise antipodes. This package, developed by David Kahle antipodean R-guru Hadley Wickham, has a neat geocoding function to obtain a spatial location. You will need a Google API to enable the geocoding function.
The antipode function takes the description of a location and a zoom level to plot a dot on the antipode location. The gridExtra package is used to create a faceted map, which is not otherwise possible in ggmap.
library(gridExtra)
library(ggmap)
api <- readLines("google.api") # Text file with the API key
register_google(key = api)
## Antipode function
antipode <- function(location, zm = 6) {
# Map location
lonlat <- geocode(location)
loc1 <- get_map(lonlat, zoom = zm)
map1 <- ggmap(loc1) +
geom_point(data = lonlat, aes(lon, lat, col = "red", size = 10)) +
theme(legend.position = "none")
# Define antipode
lonlat$lon <- lonlat$lon-180
if (lonlat$lon < -180)
lonlat$lon <- 360 + lonlat$lon
lonlat$lat <- -lonlat$lat
loc2 <- get_map(lonlat, zoom = zm)
map2 <- ggmap(loc2) +
geom_point(data = lonlat, aes(lon, lat, col = "red", size = 10)) +
theme(legend.position = "none")
grid.arrange(map1, map2, nrow = 1)
}
antipode("Rector Nelissenstraat 47 Hoensbroek", 4)
This code solves the problem I was thinking about as a child. Running the code shows that the antipodes location of the home I grew up in is not in Australia, but quite a way south of New Australia. Although I did end-up living in Australia withouth having to dig a hole in the earth.

Share this content