Cannot map poles #6

Closed
jiho opened this Issue Apr 17, 2012 · 1 comment

Projects

None yet

2 participants

jiho commented Apr 17, 2012
qmap("antarctica")

fails and produces the warnings

Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
3: In min(x) : no non-missing arguments to min; returning Inf
4: In max(x) : no non-missing arguments to max; returning -Inf

On the other side of the earth:

ggmap(get_map("greenland", zoom=4))

works

ggmap(get_map("greenland", zoom=3))

fails.

Owner
dkahle commented Apr 17, 2012

This is because mapproject fails for latitudes bigger than 80deg (or less than -80deg, I guess). See the Value section of ?mapproject.

For examples tracing the issue :

ggmap <- get_map("greenland", zoom=3)
fourCorners <- expand.grid(
  lon = as.numeric(attr(ggmap, "bb")[, c("ll.lon", "ur.lon")]), 
  lat = as.numeric(attr(ggmap, "bb")[, c("ll.lat", "ur.lat")]))
xmin <- attr(ggmap, "bb")$ll.lon
xmax <- attr(ggmap, "bb")$ur.lon
ymin <- attr(ggmap, "bb")$ll.lat
ymax <- attr(ggmap, "bb")$ur.lat

p <- ggplot(aes(x = lon, y = lat), data = fourCorners) + 
  geom_blank() + inset_raster(ggmap, xmin, xmax, ymin, ymax)            
p  # works pre-project
p + coord_map() # disappears post-project


greenland <- map(regions = 'greenland')
df <- as.data.frame(greenland[c('x','y')])
qplot(x, y, data = df, geom = 'path') # works pre-project
qplot(x, y, data = df, geom = 'path') +
  coord_map() # automatically crops image


cbind(
  df,
  with(greenland, as.data.frame(
    mapproject(x, y, projection = 'mercator')[c('x','y')])
  )
)

Nevertheless, a sensible fix must exist.

@dkahle dkahle closed this in c6b7579 Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment