oswaldosantos / ggsn

R package to add north symbols and scale bars to maps created with ggplot or ggmap
http://oswaldosantos.github.io/ggsn/
GNU General Public License v2.0
161 stars 9 forks source link

Error in grid.Call.graphics(C_setviewport, vp, TRUE) : non-finite location and/or size for viewport #34

Closed adrfantini closed 6 years ago

adrfantini commented 6 years ago

Using the latest sf:

library(ggsn); library(sf); library(ggplot2)
dsn <- system.file('extdata', package = 'ggsn')
map <- st_read(dsn, 'sp', quiet = TRUE)
map2 <- st_transform(map, 31983)
ggm1 <- ggplot(map, aes(fill = nots)) +
    geom_sf() +
    scale_fill_brewer(name = 'Animal abuse\nnotifications', palette = 8)
ggm1 +
    blank() +
    north(map)

Returns:

Error in grid.Call.graphics(C_setviewport, vp, TRUE) : 
  non-finite location and/or size for viewport

Also, ggm1 + scalebar(map, dist = 5, dd2km = TRUE, model = 'WGS84') does not show any scalebar.

oswaldosantos commented 6 years ago

Are you using ggsn 0.4.10?

adrfantini commented 6 years ago

I am using the latest github version.

Adriano Fantini

2018-05-29 14:39 GMT+02:00 Oswaldo Santos Baquero notifications@github.com :

Are you using ggsn 0.4.10?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/oswaldosantos/ggsn/issues/34#issuecomment-392760935, or mute the thread https://github.com/notifications/unsubscribe-auth/AMO2HZL8spp7huu79_0sR2Vv3g9dr-Rmks5t3UFngaJpZM4UPWyZ .

oswaldosantos commented 6 years ago

Could you post the output of sessionInfo()?

adrfantini commented 6 years ago

At the time of opening the issue I had just installed ggsn from github, but now I updated again and the error does not show anymore, and the scalebar also shows. I do not know why that happened!

Sorry for taking your time and thanks for the package!