Question

I am trying to plot a specific region in the arctic with ggmap. The center of the region is somewhere around lat. 80 lon. 0, unfortunately only a grey background and the latitude and longitude axis are shown. I tried to plot different regions and my code seems to work on every location, except regions which are beyond lat. 73.6. Here is an example of my code:

library(ggmap)
library(mapproj)
location <- get_map(location = c(lon = 0, lat = 80), zoom = 4, maptype = "hybrid")
ggmap(location)

So does anyone know, why ggmap is unable to plot this location?

Was it helpful?

Solution

I had the same problem (when trying to plot Antartica) and to get around it, I resorted to ggplot, but relying on a couple of functions from the ggmap package. As @Henrik's link suggests, the map projection seems to be the problem.

The entire idea and code is courtesy of David Kahle

Here's what you can do to get it to work for your case:

location <- get_map(location = c(lon = 0, lat = 80), zoom = 4, maptype = "hybrid")

#Create a small data frame to pass to ggplot
fourCorners <- expand.grid(
  lon = as.numeric(attr(location, "bb")[, c("ll.lon", "ur.lon")]), 
  lat = as.numeric(attr(location, "bb")[, c("ll.lat", "ur.lat")])
  )
# The inset_raster function needs 4 data coordinates. Pull it out of your "location" that you got via get_map
xmin <- attr(location, "bb")$ll.lon
xmax <- attr(location, "bb")$ur.lon
ymin <- attr(location, "bb")$ll.lat
ymax <- attr(location, "bb")$ur.lat

# Now you are ready to plot it
mp <- ggplot(fourCorners, aes(x = lon, y = lat) ) + 
 inset_raster(location, xmin, xmax, ymin, ymax)            
mp

Which gives you your "hybrid" map, centered at (Longitude=0, lat=80)

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top