<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">I have a Ubuntu 18.0.4 with R 3.6.1 system with the following releases from OSGeo for </span><span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">GEOS 3.8.0, GDAL 3.0.1, PROJ 6.2.0</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">  I have an application that requires using gstat and thus I have to use rgdal as sf objects/classes aren’t supported in gstat, only sp. (This is a bit frustrating because rpostgis uses sf, so when I import my data it is an sf datatype, convert it to sp for gstat, and then back to sf to upload…) I thought the issue originally resided in sp, but after reviewing the sp source, it comes down to the calls that the sp CRS function makes using </span><span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">rgdal::</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">. Below is a summary that shows my problem, sf links with the necessary system files and gets the correct CRS, rgdal does not. I think the issue is in how </span><span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">proj_api.h</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""> is included, specifically with not recognizing</span><span class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); background-color: rgba(255, 255, 255, 0);"> <span class="" style="color: rgb(47, 255, 18); font-family: "Andale Mono";">proj.db</span></span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""> and instead relying on </span><span class="" style="color: rgb(47, 255, 18); font-family: "Andale Mono";">proj_def.dat</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""> which was removed in PROJ 6.1 as I recall. I can confirm that there is only one set of OSGeo libraries installed and those are those are the ones that I’ve compiled and are in </span><span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">/usr/local</span><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">.</span><div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">I can trick rgdal to use the <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">proj_def.dat</span> file by adding <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">gdal/</span> and <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">proj/</span> directories from the latest windows binary *.zip to <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">~</span><span class="" style="color: rgb(47, 255, 18); font-family: "Andale Mono";">/R/x86_64-pc-linux-gnu-library/3.6/rgdal</span>. After doing this, rgdal will execute CRS, but complains that it can’t find <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">proj.db</span>   Once those files are removed it finds <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">proj.db</span>, but then can’t do CRS stuff. Win some, loose some I guess… </div><div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">After reading through a bit of the source, it seems that rgdal defaults to using the deperecated proj4 strings and does not access the newer formats in <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">proj.db</span> even though during compilation rgdal finds the db with no problem. I am not too familiar with either package, so this is conjecture based on my limited testing/research.</div><div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">As a note, if <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">$PROJ_LIB</span> is specified as an environment variable the result is <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">Path to PROJ.4 shared files: /usr/local/share/proj</span>.  But, when it is not specified the result is <span class="" style="caret-color: rgb(47, 255, 18); color: rgb(47, 255, 18); font-family: "Andale Mono";">Path to PROJ.4 shared files: (autodetected)</span>. The behavior of rgdal remains unchanged in either case.</div><div class="" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">> library(sf)</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">Linking to GEOS 3.8.0, GDAL 3.0.1, PROJ 6.2.0</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">> library(rgdal)</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">Loading required package: sp</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">rgdal: version: 1.5-1, (SVN revision 879)</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> Geospatial Data Abstraction Library extensions to R successfully loaded</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> Loaded GDAL runtime: GDAL 3.0.1, released 2019/06/28</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> Path to GDAL shared files: </span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> GDAL binary built with GEOS: TRUE </span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> Loaded PROJ.4 runtime: Rel. 6.2.0, September 1st, 2019, [PJ_VERSION: 620]</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> Path to PROJ.4 shared files: /usr/local/share/proj</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;"> Linking to sp version: 1.3-1 </span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">> CRS("+init=epsg:4269")</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">Error in CRS("+init=epsg:4269") : no arguments in initialization list</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">> st_crs(4269)</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">Coordinate Reference System:</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">  EPSG: 4269 </span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures;">  proj4string: "+proj=longlat +datum=NAD83 +no_defs”</span></div></div><div class=""><br class=""></div><div class="">Here is a coordinate transformation from NAD83 CRS to the UTM16 NAD83(2011) projection to show basic GDAL/PROJ6 functionality:</div><div class=""><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures; background-color: rgba(255, 255, 255, 0);">$ cs2cs EPSG:4269 EPSG:6345</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures; background-color: rgba(255, 255, 255, 0);">35 -84</span></div><div class="" style="margin: 0px; font-stretch: normal; line-height: normal; font-family: "Andale Mono"; color: rgb(47, 255, 18);"><span class="" style="font-variant-ligatures: no-common-ligatures; background-color: rgba(255, 255, 255, 0);">773798.10<span class="Apple-tab-span" style="white-space: pre;">       </span>3877156.69 0.00</span></div></div><div class=""><br class=""></div><div class="">I had forgotten that I originally reported the issue here <a href="https://github.com/edzer/sp/issues/59" class="">https://github.com/edzer/sp/issues/59</a> which I’ve since closed in testing for this email.</div><div class=""><br class=""></div><div class="">Below is an email exchange that drove this current email. I am unconvinced that Roger is correct. GDAL/PROJ work just fine, as does sf. A user error that he is referring to would cause those not to work/complain. The fact that I can make it work and make it not work should actually be grounds for successful bug identification.</div><div class=""><br class=""></div><div class="">Cal</div><div class=""><br class=""></div><blockquote type="cite" class=""><span class="" style="color: rgb(0, 0, 0);">On Wed, 6 Nov 2019, Cal Abel wrote:</span><br class=""><font color="#000000" class=""><br class=""></font><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="">Dr. Bivand,</div><div class=""><br class=""></div><div class="">I attempted to report a bug in rgdal but don't really have any place to put it. I reported it in the OSGeo/gdal git page, but the issue was closed:</div><div class=""><br class=""></div><div class=""><a href="https://github.com/OSGeo/gdal/issues/1988" class="">https://github.com/OSGeo/gdal/issues/1988</a></div></blockquote><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">I posted:</span><br class=""><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">Almost certainly user blunder - neither **sf** nor **rgdal** install data/share files on source install, always relying on system installs. OP almost certainly neglected to read install notes. If GDAL and PROJ utilities can find their data/share files outside R, not finding them within R could signal R packages built against a different *.so than the one found at runtime.</span><br class=""><font color="#000000" class=""><br class=""><span class=""><br class=""></span></font><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><br class=""></div><div class="">One update to the above, I tried creating symbolic links to the compiled gdal and proj directories instead of copying the windows folders and it did not work. I also tried various combinations of links/files and was not able to get it to work. The only method that worked was to copy both windows directories.</div><div class=""><br class=""></div><div class="">The temporary fix I have, while it does not produce an error it now produces warnings:"</div></blockquote><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">Do not try any fixes, you are almost certainly in error. How many versions of GDAL and PROJ are on your platform? For source installs, there should be one only, and GDAL should be built with that PROJ.</span><br class=""><font color="#000000" class=""><br class=""></font><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><br class=""></div><div class="">Warning messages:</div><div class="">1: In CPL_crs_from_epsg(as.integer(x)) :</div><div class="">GDAL Error 1: PROJ: proj_create_from_database: Cannot find proj.db</div><div class="">2: In CPL_crs_from_epsg(as.integer(x)) :</div><div class="">GDAL Error 1: PROJ: proj_create_from_database: Cannot find proj.db</div><div class=""><br class=""></div><div class="">"</div><div class=""><br class=""></div></blockquote><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">Since it cannot find the PROJ proj.db, your installation of PROJ is broken, and copying across from an older version which does not have this key file will obviously fail.</span><br class=""><font color="#000000" class=""><br class=""></font><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="">In the future, what is the best avenue for reporting bugs?</div><div class=""><br class=""></div></blockquote><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">Use the R-sig-geo list. The package is not on github and will not be migrated - it is where </span><a href="https://cran.r-project.org/package=rgdal" class="">https://cran.r-project.org/package=rgdal</a><span class="" style="color: rgb(0, 0, 0);"> says it is: </span><a href="https://r-forge.r-project.org/projects/rgdal/" class="">https://r-forge.r-project.org/projects/rgdal/</a><span class="" style="color: rgb(0, 0, 0);"> under SVN. All corresponndence through R-sig-geo, because others can correct your misapprehensions.</span><br class=""><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">Note that the nabble link is totally different, which you should have known.</span><br class=""><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">Further be aware that your usage pattern (+init=) is no longer valid in GDAL 3 and PROJ 6, and will stop working shortly. Your working example has GDAL 2 and PROJ 5, although this is not the only cause here, I think. It would be to your benefit to read </span><a href="https://proj.org/" class="">https://proj.org/</a><span class="" style="color: rgb(0, 0, 0);"> and </span><a href="https://gdal.org/" class="">https://gdal.org/</a><span class="" style="color: rgb(0, 0, 0);">, and grasp </span><a href="https://gdal.org/development/rfc/rfc73_proj6_wkt2_srsbarn.html" class="">https://gdal.org/development/rfc/rfc73_proj6_wkt2_srsbarn.html</a><span class="" style="color: rgb(0, 0, 0);">, since this is a work-related query. How you migrate your corporate workflows to GDAL 3 and PROJ 6//7 may be of considerable interest (blog, mailing list post), and I'm spending all my time trying to adapt rgdal for this major change, and do not have patience with wasted time. See </span><a href="https://github.com/r-spatial/sf/issues/1146" class="">https://github.com/r-spatial/sf/issues/1146</a><span class="" style="color: rgb(0, 0, 0);"> and </span><a href="https://github.com/r-spatial/discuss/issues/28" class="">https://github.com/r-spatial/discuss/issues/28</a><span class="" style="color: rgb(0, 0, 0);">.</span><br class=""><font color="#000000" class=""><br class=""></font><span class="" style="color: rgb(0, 0, 0);">Roger Bivand</span><br class=""><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class=""><br class=""></div></blockquote></blockquote><div class=""><div class=""><span class="" style="float: none; display: inline !important;"><b class="">Cal Abel, PhD</b></span><div class=""><a href="mailto:crabel@signalpowerandlight.com" class="">crabel@signalpowerandlight.com</a><br class=""><br class=""></div><div class=""><span class="" style="float: none; display: inline !important;"><a href="http://www.signalpowerandlight.com" class="">www.signalpowerandlight.com</a></span></div></div></div></div>
<br class=""></body></html>