-
Notifications
You must be signed in to change notification settings - Fork 12
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
gdalUtils and gdal 3.0.2 : ERROR 1: PROJ: proj_create_from_wkt: Cannot find proj.db #24
Comments
I'd guess this is the same problem/related to what I just reported here: , and that I was going to report also here. HTH, Lorenzo |
If you run this line (from above) from Windows CMD line, what happens?
|
D:\tmp>"C:\Program Files\QGIS 3.10\bin\ogr2ogr.exe" -t_srs "EPSG:2154" "rgdal.json" "rgdal.geojson" D:\tmp> |
A way to fix the issue in r-spatial/discuss#31 is to reassign properly (or set in the first place if it is not set) the "PROJ_LIB" environment variable on the fly, before issuing any GDAL command that requires it. I implemented a possible fix (at the moment, only valid for Could you try if it works also for you? You can do that by installing my fork from github: remotes::install_github("lbusett/gdalUtils", ref = "feature/projlibpath")
library(gdalUtils) and then trying commands: src_dataset <- system.file("external/tahoe_highrez.tif", package="gdalUtils")
# Command-line gdalwarp call:
gdalwarp(src_dataset,dstfile="tahoe_highrez_utm11.tif",
t_srs='+proj=utm +zone=11 +datum=WGS84',output_Raster=TRUE,
overwrite=TRUE,verbose=TRUE) and see if it works. If this seems ok/viable, the fix can be easily extended to other |
Ok, trying to get a TLDR here -- basically either rgdal or gdalUtils is causing the PROJ_LIB to change, which breaks some of the functionality?
If so, I think the simplest solution is to modify the GDAL command so this gets pre/post-appended to the command that is actually run (so I can universally change it in gdal_cmd_builder instead of having to tweak each command individually). --j |
Hi @jgrn307 , I'll reply inline:
Yes, that is correct. The "culprit" here is
The fix relies on introducing the new function
I encountered this only on Windows. It is due to the fact that at the moment the Windows
This is a good idea. However, consider that this would require moving also the HTH, Lorenzo |
Thaks for testing. Could you try installing again from CRAN, test the following: src_datasource_name <- system.file("external/tahoe_highrez_training.shp", package="gdalUtils")
dst_datasource_name <- paste(tempfile(),".shp",sep="")
# reproject the input to mercator
ogr2ogr(src_datasource_name,dst_datasource_name,t_srs="EPSG:3395",verbose=TRUE) , and then re-test after reinstalling again from my fork on github? |
Strange... it works for me... could you please share your session info?
|
|
seems that a reset of the r session is required. Could you retry after restarting the rsession/restarting rstudio, if you did not do that already? |
That should mean that it worked. file.exists(dst_datasource_name) ? |
Seems therefore that the "fix" would work. @jgrn307 What do you think of the solution introduced in lbusett@709cc02 ? I's based on moving the Lorenzo |
So this REALLY seems like an rgdal problem the more I look into it. Let me see if Bivand is willing to tweak his code a bit. It seems like if someone runs rgdal for ANY reason before gdalUtils is run, the environment variable is "lost" in a way that is going to make it very hard to recover. Am I missing something? |
No, it is a problem for those using Windows or OSX binary installs of CRAN packages, and the same problem will exist for all other packages not building from source locally (I'm not sure which, but rgdal and sf certainly, probably vapour). There is no easy way to provide half-binary Windows builds (OSX the same), depending on DLLs that the user has to install first. Yes, it is a problem, but no, there is no rgdal specific resolution. If we tweak rgdal on Windows to respect an existing PROJ_LIB environment variable, we will very quickly find that say an OSGeo4W PROJ or GDAL is a different version from the version used to build rgdal.dll, so will expect say proj/epsg not proj/proj.db. Protecting all rgdal functions on CRAN binary builds by setting and resetting PROJ_LIB (and the GDAL equivalent) on before and after each If gdalUtils required https://github.com/rwinlib/gdal2 and that built the binaries too, all the Windows CRAN binary users would be on the same page. Or gdalUtils could wrap the use in sf of the utilities as library functions. |
Roger, here's a potential very easy tweak you could make that I could easily use with gdalUtils: before you set the environment variable(s), can you simply create/set a new environment variable named something like "OLD_PROJ_LIB" and throw the "old" environment variable in there? This would then let me grab it easily (as long as I know the name of the variable) and I can do a set/reset back. Would you be willing to make this change? Just tack that right above the line you do the environment variable change? |
@edzer I think this would need to be done with sf also. |
Let's move this to: r-spatial/discuss#31 |
Full disclosure: I'm not using gdalUtils. Not trying to hijack this discussion, but I've been doing some searching after running into an apparently related issue on Mac and I thought it might be relevant for your open issue. I'm running OSX 10.15.6 Catalina. Using
Running
... with the warning repeated 50 times before exhausting. However, if I repeat exactly the same script as above, but with
Also possibly relevant, from the Terminal:
|
@JepsonNomad Post a minimal reproducible example on R-sig-geo after subscribing if need be. This is almost certainly the wrong place to ask. |
Hello,
I use gdaUtils with the gdal version from QGIS : https://www.qgis.org/fr/site/forusers/download.html
https://qgis.org/downloads/QGIS-OSGeo4W-3.10.0-2-Setup-x86_64.exe
On a command like
I have an other version of gdal from http://download.gisinternals.com/sdk/downloads/release-1911-x64-gdal-3-0-mapserver-7-4.zip in the directory d:\gdal30
I replace the system call "system(cmde, intern = TRUE)" by a small script, cf https://framagit.org/mgageo/osmdata/blob/master/scripts/ogr2ogr.R and it's good
The text was updated successfully, but these errors were encountered: