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

Add WKT2 CRS representation to example data #697

Merged
merged 3 commits into from
Dec 15, 2020
Merged

Add WKT2 CRS representation to example data #697

merged 3 commits into from
Dec 15, 2020

Conversation

jcheng5
Copy link
Member

@jcheng5 jcheng5 commented Aug 24, 2020

I received an email from Roger Bivand via CRAN:

Dear maintainer,

Your package leaflet stores data objects using classes defined
in the sp package or inheriting from those classes. From sp 1.4-* and
rgdal 1.5-*, CRS objects are now expected to have a comment containing
an WKT2 CRS representation - see:

https://www.r-spatial.org/r/2020/03/17/wkt.html

A section at the foot of

https://rgdal.r-forge.r-project.org/articles/CRS_projections_transformations.html#rebuilding-crs-objects

describes possible steps for updating CRS objects; earlier sections cover
background issues. Working around sp objects with stale CRS is already
causing difficulties, so your cooperation in upgrading will be helpful.An attempt has been made to rebuild data objects using sp::rebuild_CRS(),
and output (re-stored as version 2) may be found on my server at:

http://spatial.nhh.no/R/rebuilt_sp_objects/

The functions used are from the development version of rgdal, 1.5-17,
rev >= 1053, use:

install.packages("rgdal", repos="http://R-Forge.R-project.org")

and:

remotes::install_github("rsbivand/sp")

should you wish to make changes. Please check carefully that these objects
are as you would expect. Note that the rebuilt CRS object contains
a revised version of the input Proj4 string as well as the WKT2 string,
and may be used with both older and newer versions of sp. Objects
inheriting from sp classes but with NA CRS are not modified.

Minimal reproducible example

library(leaflet)
comment(atlStorms2005@proj4string)
comment(breweries91@proj4string)
comment(gadmCHE@proj4string)

I can confirm that with the new .rda files provided by Roger, these calls return WKT2 strings, while the old copies do not. I also tried using these objects with leaflet and everything works fine.

PR task list:

  • Update NEWS
  • Add tests (where appropriate)
    • R code tests: tests/testthat/
    • Visual tests: R/zzz_viztest.R
  • Update documentation with devtools::document()

@jcheng5 jcheng5 requested a review from schloerke August 24, 2020 19:27
@jcheng5 jcheng5 added this to the v2.1 milestone Aug 25, 2020
@jcheng5 jcheng5 marked this pull request as draft August 25, 2020 22:52
@jcheng5
Copy link
Member Author

jcheng5 commented Aug 25, 2020

Something is wrong with the data, our unit tests convert them from sp to sf and it's throwing errors. I have an email out to Roger asking for guidance.

Edit: Roger figured it out, was due to a combination of a buglet in sf and my system's old GDAL/PROJ libraries.

@jcheng5
Copy link
Member Author

jcheng5 commented Aug 26, 2020

Tests are warning, e.g.:

test-normalize-2.R:24: warning: normalize
sf layer has inconsistent datum (+proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs ).
Need '+proj=longlat +datum=WGS84'

Relates to #505, r-spatial/mapview#72. In #505, I promised to get back to the question of automatically transforming sp/sf input after the next CRAN release, but never did. This could be the right time to do it.

@tim-salabim
Copy link
Contributor

@jcheng5 what's your take here? Should leaflet do on-the-fly projection or not? It's of course convenient for the user, but somewhat questionable from an educational point of view (from my experience as a geodata scientist).

r-spatial/sf#1474

Without the sf fix, tests were failing due to errors when
sf::st_as_sf() was called on atlStorms2005, breweries91,
and gadmCHE.
@jcheng5
Copy link
Member Author

jcheng5 commented Oct 30, 2020

Rebased against master and force-pushed, to pick up the change from Travis to GitHub Actions, and dropped the Remotes field as the sf we need is on CRAN.

@jcheng5 jcheng5 marked this pull request as ready for review October 30, 2020 21:38
@jcheng5
Copy link
Member Author

jcheng5 commented Oct 30, 2020

This seems to work fine now, I think the sf update fixed the warnings.

@jcheng5 jcheng5 merged commit 2ad8359 into master Dec 15, 2020
@jcheng5 jcheng5 deleted the sp-compat branch December 15, 2020 02:06
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

Successfully merging this pull request may close these issues.

2 participants