sf icon indicating copy to clipboard operation
sf copied to clipboard

Error message from vctrs::vec_cast_common doesn't include CRS

Open etiennebr opened this issue 5 years ago • 0 comments

The error message from #799

#> Error: Can't combine `x` <sfc_GEOMETRY> and `y` <sfc_GEOMETRY>.

Is confusing because one would expect two sfc_GEOMETRY to be combinable.

I haven't looked in-depth, but it seems that sf:::common_crs would raise an appropriate error and the correct message.

Minimal Reprex:

library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.2, PROJ 6.2.1
vctrs::vec_cast_common(
    x = st_as_sfc(c("POINT(1 3)"), crs = 4326), 
    y = st_as_sfc("POINT(2 2)", crs = NA_crs_)
    )
#> Error: Can't combine `x` <sfc_GEOMETRY> and `y` <sfc_GEOMETRY>.
#> x Some attributes are incompatible.
#> ℹ The author of the class should implement vctrs methods.
#> ℹ See <https://vctrs.r-lib.org/reference/faq-error-incompatible-attributes.html>.

etiennebr avatar Aug 10 '20 12:08 etiennebr