Closed edzer closed 3 years ago
My commits/pushes to my forks of sf and sp: https://github.com/rsbivand/sf/commit/cd26c08c34781206ef932c32ec0d0797ab321e7f https://github.com/rsbivand/sp/commit/fbe5b883cde864861ac7202bad3122aec824b03e give (with no installed rgdal - the fixed just trust sf):
> library(sf)
Linking to GEOS 3.10.0dev, GDAL 3.3.0, PROJ 8.0.1
> as(st_crs(4326), "CRS")
Coordinate Reference System:
Deprecated Proj.4 representation: +proj=longlat +datum=WGS84 +no_defs
WKT2 2019 representation:
GEOGCRS["WGS 84",
ENSEMBLE["World Geodetic System 1984 ensemble",
MEMBER["World Geodetic System 1984 (Transit)"],
MEMBER["World Geodetic System 1984 (G730)"],
MEMBER["World Geodetic System 1984 (G873)"],
MEMBER["World Geodetic System 1984 (G1150)"],
MEMBER["World Geodetic System 1984 (G1674)"],
MEMBER["World Geodetic System 1984 (G1762)"],
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ENSEMBLEACCURACY[2.0]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
USAGE[
SCOPE["Horizontal component of 3D system."],
AREA["World."],
BBOX[-90,-180,90,180]],
ID["EPSG",4326]]
with an extra argument to sp::CRS()
. I think that in sf/R/sp.R
:
nm <- "CRS"
attr(nm, "package") <- "sp"
obj <- new(nm, projargs=from$proj4string)
comment(obj) <- from$wkt
will also work, but may make sf depend on 'methods - untried.
I reverted the additional sp::CRS()
argument to avoid depending on a specific sp version; the use of new("CRS", ...)
did not show any extra problems in check:
https://github.com/rsbivand/sf/commit/44bbae31c82a2855d0c25b19e9194fe688d71c4b
https://github.com/rsbivand/sp/commit/8f3be3e9eac5dbd9aae4716922a41bc094979edf
So new()
is my preference and also signals a start to using PROJ/GDAL through sf even when constructing an sp "CRS"
object. The commit and reversion for sp are in PR #103.
Thanks, makes a lot of sense!
This came up here: https://github.com/rvalavi/blockCV/issues/18
which calls
CRS(SRS_string = st_crs(4326)$wkt)
- this should stop or accept the wkt without checking. Also settingdoCheckCRSArgs=FALSE
does not help.