Closed
Description
This is an issue against PR #3659, which is currently on hold pending the next minor ggplot2 release. I'm filing this so I won't forget. This should probably be fixed before the PR gets merged.
In a nutshell, in some cases coord_sf()
encounters numeric issues when trying to calculate plot limits and errors out. This is fine, but the error message should inform the user how to work around this problem (by setting default_crs = NULL
). Also, these numeric issues probably shouldn't arise when lims_method = "geometry_bbox"
, but I haven't checked this yet carefully. Reprex below.
library(sf)
library(ggplot2)
grid <- st_sf(st_make_grid(what = 'polygons'))
# Robinson, works
ggplot(grid) + geom_sf() + coord_sf(crs = st_crs(54030))
# Mollweide, doesn't work, that's Ok but error message is poor
ggplot(grid) + geom_sf() + coord_sf(crs = st_crs(54009))
#> Error: Scale limits cannot be mapped onto spatial coordinates.
# Mollweide, doesn't work, but probably should
ggplot(grid) + geom_sf() +
coord_sf(crs = st_crs(54009), lims_method = "geometry_bbox")
#> Error: Scale limits cannot be mapped onto spatial coordinates.
# Mollweide, works
ggplot(grid) + geom_sf() +
coord_sf(crs = st_crs(54009), default_crs = NULL)
Created on 2020-04-11 by the reprex package (v0.3.0)