-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
GDAL 3.3.2 changes/deprecates AutoIdentifyEPSG() #466
Comments
Thank you for reporting. Let me explain some context so you will be able to guide me toward better solutions. Objects from
A LAS file can only store the EPSG code to record the CRS. At R level when a user want to assign a CRS to a LAS object they will likely use another spatial object this way
I the next release I already removed dependency to
|
Good to hear of your progress with sf!
|
Sure your options are valid but what about this case: r = sp::CRS("+proj=utm +zone=18 +datum=NAD83 +units=m +no_defs ")
crs = sf::st_crs(r)
crs$epsg
#> NA
rgdal::showEPSG(r@projargs)
#> "26918" I also made few more tests to see if it works in most probable use cases. It seems to me that I said I removed Considering the numerous previous issues you opened, I feel that one day or another So at this stage do you think I should start the work as soon as possible? I feel more and more that maintaining backward compatibility is a dead end issue and one day or another I'm comfortable with # ===============
f = system.file("external/lux.shp", package="raster")
p = raster::shapefile(f)
crs = sf::st_crs(p)
crs$epsg
#> [1] 4326
p = sf::st_read(f)
crs = sf::st_crs(p)
crs$epsg
#> [1] 4326
lidR:::.find_epsg_code(crs)
#> [1] 4326
# ===============
f <- system.file("extdata", "lake_polygons_UTM17.shp", package = "lidR")
p = raster::shapefile(f)
crs = sf::st_crs(p)
crs$epsg
#> [1] 26917
p = sf::st_read(f)
crs = sf::st_crs(p)
crs$epsg
#> [1] 26917
lidR:::.find_epsg_code(crs)
#> [1] 26917
# ===========
tif = system.file("tif/L7_ETMs.tif", package = "stars")
r = stars::read_stars(tif)
crs = sf::st_crs(r)
crs$epsg
#> [1] NA
r = terra::rast(tif)
crs = sf::st_crs(r)
crs$epsg
#> [1] NA
r = raster::raster(tif)
#> Warning in showSRID(SRS_string, format = "PROJ", multiline = "NO", prefer_proj =
#> prefer_proj): Discarded datum unknown in Proj4 definition
crs = sf::st_crs(r)
crs$epsg
#> [1] NA
rgdal::showEPSG(crs$input)
#> Error in rgdal::showEPSG(crs$input): Can't parse PROJ.4-style parameter string
# ===============
tif = system.file("ex/meuse.tif", package = "terra")
r = stars::read_stars(tif)
crs = sf::st_crs(r)
crs$epsg
#> [1] NA
r = terra::rast(tif)
crs = sf::st_crs(r)
crs$epsg
#> [1] NA
r = raster::raster(tif)
crs = sf::st_crs(r)
crs$epsg
#> [1] NA
rgdal::showEPSG(crs$input)
#> [1] "OGRERR_UNSUPPORTED_SRS"
# ==============
load(url("http://github.com/mgimond/Spatial/raw/master/Data/raster.RData"))
crs = sf::st_crs(bath)
crs$epsg
#> [1] NA
rgdal::showEPSG(crs$input)
#> [1] "4326" |
crs = sf::st_crs(26917)
crs$epsg
# NULL |
I've linked your findings to the relevant sf issue, as you see. Our plan is to reduce risk by retiring rgdal, rgeos and maptools which I maintain, but which might not receive the attention they require. I retired in April, am 70, and now in good health, but the risk is there. For vector work, sf covers effectively everything (maybe stepping carefully around |
I think the signals from upstream (GDAL community) are clear: we should stop assuming proj.4 strings can give us EPSG IDs for cases where the proj4 string implicitly assumes axis order long/lat and the EPSG definition has order lat/long. |
@Jean-Romain , for me:
(all most recent). What are your package and extSoftVersion details for #466 (comment) ? |
I watched Edzer's useR keynote on Youtube. I now better understand the state of library(sf)
Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1 My packages are updated from the It is now clear that I have to fully move to setClass(
Class = "LAS", contains = "Spatial",
representation(data = "data.table", header = "LASheader", index = "list")
) The goal of such inheritance was to get a slot for CRS and a compatibility by inheritance with other packages. For example sf::st_crs(las) # works
raster::projection(las) # works The biggest problem so far is that the CRS is a library(lidR)
LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
las = readLAS(LASfile)
sflas = sf::st_as_sf(as.spatial(las))
format(object.size(las), "Mb")
#> "5.3 Mb"
format(object.size(sflas), "Mb")
#> "37.7 Mb" So my question is: which low level |
That one fails too (at least with my versions of gdal and proj) crs = sf::st_crs(sp::CRS("+init=epsg:26917"))
crs$epsg
# NA
crs = sf::st_crs(sp::CRS(SRS_string = "EPSG:26917"))
crs$epsg
# 26917 |
When user input is a PROJ4 string, the connection is lost, in the WKT2 representation, the |
I removed almost all occurrences of crs <- sp::CRS("+init=epsg:26918") # Fails on Solaris: crs <- sp::CRS(SRS_string = "EPSG:26918") But since I can no longer retrieve the EPSG code from In lidR the occurence of
I'm expecting to get things cleaner when my classes will no longer inherit |
When you are closer, pleae let me know, and I'll try to test on a system with the same GEOS, PROJ and GDAL versions as used by CRAN Solaris. They are similar to those found on LTS CentOS and Debian typically used in large labs. |
Well the current code passes CRAN check and the 1345 unit tests on github actions for R-devel and R-release. So you can test it right now to check if it passes with other versions of GEOS, PROJ, GDAL. Thanks |
This is the check directory without the source and installed package: There is one test error in
so I think the error messages differ slightly from those in the test. I added |
Thank you for reporting. I identified the problem. wkt(las) <- "INVALID" Was expected to trigger an error saying that It can only be a problem with old GDAL/PROJ + LAS format with WTK support. In this case test_that("Set an invalid code or WKT fails", {
expect_error({ epsg(las) <- 200800 }, "Invalid epsg")
if (rgdal::new_proj_and_gdal())
expect_error({ wkt(las) <- "INVALID" }, "Invalid WKT")
else
expect_error({ wkt(las) <- "INVALID" }, "WKT strings are no longer supported in lidR with old versions of GDAL/PROJ")
}) |
Good, check gets past that error now, but fails at the line 100 on wkt2CRS(): |
Ho crap ! Of course it has cascading consequences... It's such a pitty it is so complex to test myself... anyway. I fixed the 3 errors again by skipping stuff for old GDAL/PROJ By the way, when I will move to full |
Next failure in test-las_check:83:
or something similar - more details in issue, which was about GEOS, but the same principles apply. |
Always the same, trying to put a WKT string with old GDAL/PROJ fails. I |
And line 104 too, I think it is |
Well, cascading effects go more in depth than expected. As I said earlier I was not sure of what I was doing. I could fix it with a |
I tried to remove gdal and proj to install older versions but the oldest I can get in repos are gdal 3.0.1 and proj 6.3.0. So even making efforts it is impossible to reproduce 😞 |
Yes, I know, I can carry on merging from your upstream, generating the revised package tarball and running checks on my laptop, which has the old external software versions, at least for another 10 days. I think sf can generate WKT (not WKT2) on older PROJ/GDAL, and can turn WKT to a
might work for Tomorrow I'm looking after grandchildren, so not so responsive ... |
That seems the very best options if it works. I'm now using However I still skip some unit tests because many of the test are written with Don't worry with the timing I also have kids to take care of 😉. Thanks for you help. |
Now looks as though check is the same for PROJ 5.2.0 and GDAL 2.2.4 as PROJ 8.1.1 and GDAL 3.3.2 (latest). Using sf anyway bars GDAL < 2, but that is acceptable, only rgdal still supports GDAL 1, because it was started such a long time ago, and we haven't heard any complaints with regard to sf. |
Very good! So we no longer have any occurrence of I'll start a project of rebuilding my I'm closing this issue that is resolved. Thank you for your time |
I think I may have a similar problem. From a database df I want to transform the lon-lat data to utm. I am quite new to R and this line originally worked: sp <- SpatialPoints(df[,c("longitude","latitude")],proj4string=CRS("+init=epsg:4326 +proj=longlat
+ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 ")) however, when I transformed it into utm data using: sp <- SpatialPoints(df[,c("longitude","latitude")],proj4string=CRS("+init=epsg:4326 +proj=longlat
+ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 ")) an error appeared saying that I needed After struggling with it I installed the libraries using the terminal (UBUNTU 18.04) but now I have the following output when I run the first order: NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
Error in CRS("+init=epsg:4326 +proj=longlat \n+ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 ") :
no system list, errno: 2 Can anyone help me please? Thank you |
@annamuji this has nothing at all to do with this issue. Please do not hijack development issues to ask user questions. Please do use the R-sig-geo list after subscribing https://stat.ethz.ch/mailman/listinfo/R-SIG-Geo (this is where a motivated answer can be expected), or StackOverflow. Please understand that you need to do much more yourself if you choose not to use CRAN binaries for Windows or MacOS; on other platforms, you have to install packages from source, satisfying their external requirements listed on their CRAN landing pages, for rgdal https://cran.r-project.org/package=rgdal. Your installation of rgdal is completely broken, because your system does not adequately satisfy the requirements. Very likely you have installed multiple versions of GDAL and/or PROJ, and only you or your local support can sort this out. See also https://github.com/r-spatial/sf/#multiple-gdal-geos-andor-proj-versions-on-your-system. Preferably use sf not *sp. |
ok. Thank you! sorry for hijacking. I'll try to follow the instructions and if I don't find the solution I'll post it on the correct forum. |
You use
rgdal::showEPSG()
in.find_epsg_code()
in the"CRS"
branch. This fails check with PROJ 8.1.1 and GDAL 3.3.2 (see also r-spatial/sf#1776).testthat.Rout.fail.zip
You should not use the rgdal function; I do not know when or if these very old interfaces may be updated. Note that rgdal, rgeos and maptools will not be developed further, and will be withdrawn by 2024-01-01 at the latest.
The text was updated successfully, but these errors were encountered: