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

Further PROJ/GDAL CRS vulnerability #426

Closed
rsbivand opened this issue Sep 3, 2020 · 10 comments
Closed

Further PROJ/GDAL CRS vulnerability #426

rsbivand opened this issue Sep 3, 2020 · 10 comments

Comments

@rsbivand
Copy link

rsbivand commented Sep 3, 2020

I'm seeing further trouble with constructions like sp::proj4string(out) <- sp::proj4string(l) in R/od-funs.R, line 397, which should probably be something like slot(out, "proj4string") <- slot(l, "proj4string") to be sure to transfer the WKT2 comment. It is likely that +towgs84= will become fragile soon-ish. The problem I hit was running the toptail_buff() example, where sp::identicalCRS() failed in over().

> r_toptail <- toptail_buff(routes_fast, zones)
Error in over(x, geometry(i)) : identicalCRS(x, y) is not TRUE
In addition: Warning messages:
1: In sp::proj4string(l) : CRS object has comment, which is lost in output
2: In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
  Discarded datum Unknown based on WGS84 ellipsoid in CRS definition
Robinlovelace added a commit that referenced this issue Sep 3, 2020
@Robinlovelace
Copy link
Member

Thanks Roger. The above commit converts it to an sf-native function. Does that solve the issue from you perspective? Overall I think a gradual deprecation of sp in this package is the most time efficient way forward. That function incidentally could be very useful for anonymising GPS traces but I've never used it in an applied setting.

@Robinlovelace
Copy link
Member

Also added this: 9cd4c0f

@Robinlovelace
Copy link
Member

Heads-up @rsbivand it seems like many things fail now with early versions of PROJ. To fix the failing examples, which I think also affect CRAN test results, I'm adding these lines before running offending examples:

#' lib_versions <- sf::sf_extSoftVersion()
#' lib_versions
#' # fails on some systems (with early versions of PROJ)
#' if(lib_versions[3] >= "6.3.1") {

is that a valid approach?

@rsbivand
Copy link
Author

rsbivand commented Sep 4, 2020

Either that, or use only sf >= 0.9-6 (coming very soon). CRAN spotted the problem some days after Joe Cheng hit it in leaflet. sf had not conditioned on PROJ/GDAL versions in coercing CRS to crs, so fed a WKT2 string to software versions that did not handle modern WKT2 adequately. From 0.9-6, sf uses the Proj4 string of the CRS object to generate its WKT when only older GDAL/PROJ (pre-barn-raising) are present. I'd say wait for sf 0.9-6.

@Robinlovelace
Copy link
Member

Well the tests are passing now. I've just replied to an email from CRAN copying you in asking about legacy versions of PROJ etc. Impressive that the next version of sf ensures backwards compatibility, let me know if you'd like me to test.

I think that the errors that recent changes in stplanr were designed to address still appear with PROJ < 6 even with the development version of sf.

@rsbivand
Copy link
Author

rsbivand commented Sep 4, 2020 via email

@Robinlovelace
Copy link
Member

Sure - tests on dev sf and old PROJ documented here: #428

I recall previous tests with dev sf failed on the same system so I expect the CI to fail on Ubuntu 16.04.

@Robinlovelace
Copy link
Member

Update @rsbivand here is an example of an error on dev sf with an old version of PROJ that works with newer PROJ versions:

 Warning in CPL_transform(x, crs, aoi, pipeline, reverse) :
  GDAL Error 1: No PROJ.4 translation for source SRS, coordinate transformation initialization has failed.
Error in CPL_transform(x, crs, aoi, pipeline, reverse) : 
  OGRCreateCoordinateTransformation() returned NULL: PROJ available?
Calls: geo_projected ... st_transform -> st_transform.sfc -> structure -> CPL_transform
Execution halted
* checking examples with --run-donttest ... ERROR
##[error]Running examples in ‘stplanr-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: geo_projected
> ### Title: Perform GIS functions on a temporary, projected version of a
> ###   spatial object
> ### Aliases: geo_projected gprojected
> 
> ### ** Examples
> 
> lib_versions <- sf::sf_extSoftVersion()
> lib_versions
          GEOS           GDAL         proj.4 GDAL_with_GEOS     USE_PROJ_H 
       "3.7.1"        "2.2.2"        "4.9.2"         "true"        "false" 

@Robinlovelace
Copy link
Member

@Robinlovelace
Copy link
Member

That's on sf 0.9-6: https:/ropensci/stplanr/runs/1070993227#step:8:56

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