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

Broken CRS in fortcoming/newest PROJ/GDAL #1

Closed
rsbivand opened this issue Sep 2, 2021 · 6 comments
Closed

Broken CRS in fortcoming/newest PROJ/GDAL #1

rsbivand opened this issue Sep 2, 2021 · 6 comments

Comments

@rsbivand
Copy link

rsbivand commented Sep 2, 2021

You are using "proj=utm" with no zone number, which has never been valid. This invalidity causes errors in the most recent PROJ/GDAL. I think (as in PredictiveEcology/NetLogoR#43) this may be an attempt to trick raster into seeing the positional data as planar/projected. You should always use an appropriate declaration of coordinate reference systems. The package will fail CRAN checks and break for users as the newest (and best) PROJ/GDAL software propagates.

testthat.Rout.fail.zip
00check.log

Note that rgdal, rgeos and maptools will not be developed further, and will be withdrawn by 2024-01-01 at the latest. This means that you should transition to sf and either stars or terra (raster uses rgdal and rgeos).

@scbrown86
Copy link
Member

@seanhaythorne in tests/testthat/test_region.R you could replace the crs settings with
crs = "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" which is a proj4 string for an equirectangular projection. As Roger mentioned, it is just a check to see if an error is thrown with some planar/projected data so it doesn't need to be too specific.

e.g. line 38-40, would become

raster3 <- raster::raster(vals = c(NA, NA, 4, 6, NA, 2, NA, 7, NA, NA, 5, NA, 1, 3, NA, NA),
                          nrows = 4, ncol = 4, xmn = 0, xmx = 4000, ymn = 0, ymx = 4000,
                          crs = "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs")

We could also replace with

raster3 <- raster::raster(vals = c(NA, NA, 4, 6, NA, 2, NA, 7, NA, NA, 5, NA, 1, 3, NA, NA),
                          nrows = 4, ncol = 4, xmn = 0, xmx = 4000, ymn = 0, ymx = 4000,
                          crs = "EPSG:32663")

which is equivalent.

From a very quick check, this issue only occurs in the testthat/test_region.R file.

I do agree that transitioning to terra for handling rasters is probably a good move, although it would require a significant rewrite and checks of some code.

@rsbivand
Copy link
Author

rsbivand commented Sep 2, 2021

Yes, this is also equivalently EPSG:4087, but unlike +proj=utm without a zone, is valid. I don't see any difference between 4087 and 32663. It is possible that "EPSG:32663" is for newer GDAL/PROJ only, unchecked.

@seanhaythorne
Copy link
Member

seanhaythorne commented Sep 3, 2021

Hi Roger,
Thanks for notifying us, and further suggestions on a valid CRS value.

Thanks for the suggested solution Stuart.

@rsbivand
Copy link
Author

rsbivand commented Sep 6, 2021

The +proj=utm" problem is caused by OSGeo/PROJ#2672 from OSGeo/PROJ#2671 and applies in PROJ >= 8, probably backported to 8.0.1 and applies in 8.1.*. Previously a non-existing zone 0 was generated.

@rsbivand
Copy link
Author

This serious vulnerability remains. As soon as any of the CRAN test platforms starts using PROJ >= 8, you'll see failures there. I advise updating this quickly.

@seanhaythorne
Copy link
Member

Hi Roger,
We've uploaded the changes (as above) to CRAN.
Cheers,
Sean

This issue was closed.
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

3 participants