Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRS returns NA when rgdal is not installed #107

Closed
edzer opened this issue Jun 14, 2021 · 3 comments
Closed

CRS returns NA when rgdal is not installed #107

edzer opened this issue Jun 14, 2021 · 3 comments

Comments

@edzer
Copy link
Owner

edzer commented Jun 14, 2021

This came up here: rvalavi/blockCV#18

> as(st_crs(4326), "CRS")
CRS arguments: NA 

which calls CRS(SRS_string = st_crs(4326)$wkt) - this should stop or accept the wkt without checking. Also setting doCheckCRSArgs=FALSE does not help.

@rsbivand
Copy link
Contributor

rsbivand commented Jun 15, 2021

My commits/pushes to my forks of sf and sp:
rsbivand/sf@cd26c08
rsbivand@fbe5b88
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.

rsbivand added a commit to rsbivand/sp that referenced this issue Jun 17, 2021
@rsbivand
Copy link
Contributor

rsbivand commented Jun 17, 2021

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:
rsbivand/sf@44bbae3
rsbivand@8f3be3e
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.

@edzer
Copy link
Owner Author

edzer commented Jun 17, 2021

Thanks, makes a lot of sense!

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Sep 20, 2021
# version 1.0-2
* `st_read()` and `st_write()` using GDAL handle binary attributes
  (OFTBinary fields) ; #1721

* a `pivot_longer` method is added for `sf` objects (the `data.frame`
  method works, but raises a warning)

* `rbind.sf` preserves primary geometry column; #1717

* `configure` constrains using `--static` to `Darwin` platform; #1702,
  #1712, #1713

* old-style `crs` objects created with sf < 0.9-0 generate a message,
  and will cause a warning in the future.

* when `st_crs()` is called with a WKT2 as text input, its `input`
  field will be replaced with the CRS name (if it has one).

* GEOS (>= 3.9.0) operations use `GEOSGeom_setPrecision_r` to set
  precision of geometries; #1535

* `st_read()` with specified `query` ignores argument `layers`, and
  warns if it is given; #1444


# version 1.0-1
* fix regression in `st_intersection()`: when using s2 attributes were
  assigned wrongly; #1704

* `crs` (sf) to `CRS` (sp) conversion no longer needs validation by
  `rgdal`; edzer/sp#107

* retrieve ESRI's WKT version of CRS by `st_crs(id)$WKT1_ESRI`; #1690


# version 1.0-0
* add `s2` to Imports:

* add Dewey Dunnington to contributors

* `sf_use_s2()` prints a message when using s2 has been switched to on or off.

* use `s2` spherical geometry as default when coordinates are ellipsoidal. This can
  be switched off (defaulting to planar geometry, using GEOS, as in sf < 1.0-0)
  by setting environment variable `_SF_USE_S2` to `false` before package `sf`
  is loaded, or by `sf_use_s2(FALSE)`; #1649

* `st_nearest_feature()` with missing `y` returns nearest features in
  the remaining set of `x`; r-spatial/s2#111

* `st_write()` gains an argument `config_options` to set GDAL config
  options; #1618

* fix regression in `sf_project(..., keep = TRUE)`; #1635
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants