Open MichaelChirico opened 1 year ago
I'm relatively sure ggplot2 assumes that when {sf} is installed, the GDAL drivers work as intended.
I agree that the error message isn't helpful, but it is thrown from an {sf} function so there is little control that ggplot2 has over the message other than wrapping every piece of {sf} related code in tryCatch()
blocks.
Other than maybe putting the geom_map()
examples that use coord_sf()
in if (require("sf"))
blocks, I'm not sure what ggplot2 can do about this issue.
{sf} owns the error message, but {ggplot2} owns the map data & I would guess could be responsible for knowing where it comes from & thus what drivers are needed to process it?
@edzer WDYT? Is there anything reasonably straightforward {ggplot2} and/or {sf} could do to help with the error messaging here?
@MichaelChirico I'm not sure; can you provide a reprex that triggers this, or point to where it happens? I've never seen the no arguments in initialization list
error, I believe.
I can point to the line causing it:
But it will be hard to offer a reprex I'm afraid, sorry :\
I can only find the error message here, but that should not be callable (it's part of a standalone app, not the PROJ library we use). What does sf::sf_extSoftVersion()
give on your system?
I'll have to return to this when I'm off leave in May
sf::sf_extSoftVersion()
# GEOS GDAL proj.4 GDAL_with_GEOS USE_PROJ_H PROJ
# "3.5.0" "3.6.0dev-7f16b09a89" "7.0.0" "true" "false" "7.0.0"
That's a pretty old software stack; does the error persist with updated sys reqs?
I'll report back when it's updated but that may take years :)
We are observing this test failure:
Probably this is related to missing certain GDAL drivers. But I hope you agree the error message is not very helpful. I'm not sure if this is something on the ggplot2 or the sf side; I know sf offers some things we could use to escape here e.g.
sf_extSoftVersion()
oris_driver_available()
:https://github.com/r-spatial/sf/blob/b798413d4cd681cd173f9bdc110f2a014555ee09/tests/testthat/test_read.R#L176
https://github.com/r-spatial/sf/blob/b798413d4cd681cd173f9bdc110f2a014555ee09/tests/testthat/test_read.R#L121
Happy to offer more details as needed but I'm not sure what would help.
FWIW, the issue also causes some examples to fail:
https://github.com/tidyverse/ggplot2/blob/519bc83942d93bca4777b75ab3f9f79d3200b745/man/geom_map.Rd#L125-L162
https://github.com/tidyverse/ggplot2/blob/519bc83942d93bca4777b75ab3f9f79d3200b745/man/sf_transform_xy.Rd#L27-L43