dkahle / ggmap

A package for plotting maps in R with ggplot2
763 stars 231 forks source link

Error message on creating simple maps which worked yesterday. #353

Closed SwultCode closed 8 months ago

SwultCode commented 9 months ago

number of rows of matrices must match

Hey, ggmap was working just fine yesterday, when I used it today I couldn't make any large maps, by large I mean a big bounding box, the zoom isn't the issue. Whenever I make a map, i.e. one of europe, I get an error of Error in f(init, x[[i]]) : number of rows of matrices must match (see arg 2). When I change the bounding box for ggmap to be smaller it works, so I assume it's an issue somewhere there.

Below is a reproduce-able example of the error, it continues to happen after I restart r and my computer.

library(ggmap)
lonlatTest = data.frame(lon=c(-40,15), lat=c(30,0))
qmplot(lon,lat,data=lonlatTest,zoom=5)

Error in f(init, x[[i]]) : number of rows of matrices must match (see arg 2)

xp-song commented 9 months ago

I've also experienced this in the function get_map(). I input a bounding box and set source = "stamen". The error traceback seems to suggest that it happens within the stitch() function in get_stamenmap() Screenshot 2023-10-04 at 15 36 43

aradzikbys commented 9 months ago

Hello, same issue here - ggmaps were working perfectly yesterday, today I'm facing same error - I've even tried code from some web tutorial to make sure it's not caused by spelling: Source: https://jtr13.github.io/cc19/stamen-maps-with-ggmap.html

library(ggmap) bbox <- c(bottom = 25.75, top = 49 , right = -67, left = -125) usmap <- get_stamenmap(bbox = bbox, zoom = 6, maptype = 'toner-lite') ggmap(usmap) After running there is an error: image

ryurko commented 9 months ago

I'm experiencing the exact same error for code that used to work: library(ggmap) US <- c(left = -125, bottom = 10, right = -67, top = 49) map <- get_stamenmap(US, zoom = 5, maptype = "toner-lite")

ZacWarham commented 9 months ago

I had the same issue but after some digging it turns out that Stamen Maps no longer hosts tiles - manually creating a URL and visiting shows service unavailable. This would require a lot of reworking to use a third-party cache of the Stamen Maps or trying to link to the API for the new host similar to how Google Maps requires an API key

ZacWarham commented 9 months ago

I had the same issue but after some digging it turns out that Stamen Maps no longer hosts tiles - manually creating a URL and visiting shows service unavailable. This would require a lot of reworking to use a third-party cache of the Stamen Maps or trying to link to the API for the new host similar to how Google Maps requires an API key

Turns out the team at StadiaMaps created a PR for this a while ago https://github.com/dkahle/ggmap/pull/351 which adds a register_stadiamaps() function and replaces get_stamenmap with get_stadiamap

Current workaround until @dkahle merges the PR (skip step 3 if reading this after merge and just update your install instead)

  1. Create account for Stadia Maps (they have a free option but depends on your use case)
  2. Create a 'Property' on your account and get an API key
  3. Install this fork https://github.com/stadiamaps/ggmap
  4. register your API key using register_stadimaps()
  5. Replace all instances of get_stamenmap with get_stadiamap
  6. Make sure to change the tile type to the new format (there will be an error if incorrect type)

Official instructions found in https://github.com/dkahle/ggmap/issues/350#issuecomment-1750329547

aradzikbys commented 9 months ago

Regarding point 3 >> details on re-instalation of ggmap can be found here: https://docs.stadiamaps.com/guides/migrating-from-stamen-map-tiles/#ggmap

dkahle commented 8 months ago

I believe this is fixed by 191159d; please reopen if that isn't the case.