Evening,
Any ideas on the below would be great please. sf can't find pcs.csv .
> install.packages('sf')
Installing package into â/home/james/R/x86_64-pc-linux-gnu-library/3.4â
(as âlibâ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.7-1.tar.gz'
Content type 'application/x-gzip' length 8330564 bytes (7.9 MB)
==================================================
downloaded 7.9 MB
* installing *source* package âsfâ ...
** package âsfâ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.2
checking GDAL version >= 2.0.0... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/2.2/pcs.csv readable... no
configure: error: pcs.csv not found in GDAL data directory.
ERROR: configuration failed for package âsfâ
* removing â/home/james/R/x86_64-pc-linux-gnu-library/3.4/sfâ
Warning in install.packages :
installation of package âsfâ had non-zero exit status
The downloaded source packages are in
â/tmp/Rtmpm4SVOz/downloaded_packagesâ
Running gdal-config --datadir gives me
gdal-config --datadir
/usr/share/gdal/2.2
However that directory does not exist. I previously installed GDAL 2.6 from NextGIS but then removed it as it was conflicting with something else. This
james:/usr/share/gdal$ ls
1.11 2.6 CMake
I'm in a bit of a pickle . How can I 'create' a 2.2 folder in the share/gdal folder? Why wasn't it made when I installed GDAL 2.2 from ubuntugis/unstable ?
Thanks
James
IIRC, you can set the environment variable GDAL_DATA to the diretory where this stuff resides. But then, you need to know it. On my system (ubuntugis-unstable) it is /usr/share/gdal. Maybe it helps to remove all gdals you now have, and only install 2.2.x?
Hi @edzer . I thought I had done so, but on checking I hadn't removed the gdal-data library. Which I have now done, and installed 2.2 . But sf still won't install properly. Any ideas please?
install.packages('sf')
Installing package into â/home/james/R/x86_64-pc-linux-gnu-library/3.4â
(as âlibâ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_0.7-1.tar.gz'
Content type 'application/x-gzip' length 8330564 bytes (7.9 MB)
==================================================
downloaded 7.9 MB
* installing *source* package âsfâ ...
** package âsfâ successfully unpacked and MD5 sums checked
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.2
checking GDAL version >= 2.0.0... yes
checking for gcc... gcc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -std=gnu99 accepts -g... yes
checking for gcc -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /usr/share/gdal/2.2/pcs.csv readable... yes
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... yes
configure: pkg-config proj exists, will use it
checking proj_api.h usability... yes
checking proj_api.h presence... yes
checking for proj_api.h... yes
configure: PROJ: 4.9.2
checking for pj_init_plus in -lproj... yes
checking PROJ: epsg found and readable... yes
checking PROJ: conus found and readable... yes
checking for geos-config... /usr/local/bin/geos-config
checking geos-config usability... yes
configure: GEOS: 3.6.2
checking GEOS version >= 3.4.0... yes
checking geos_c.h usability... yes
checking geos_c.h presence... yes
checking for geos_c.h... yes
checking geos: linking with -L/usr/local/lib -lgeos_c -L/usr/local/lib -lgeos... yes
configure: Package CPP flags: -I/usr/include/gdal -I/usr/local/include
configure: Package LIBS: -lproj -L/usr/lib -lgdal -L/usr/local/lib -lgeos_c -L/usr/local/lib -lgeos
configure: creating ./config.status
config.status: creating src/Makevars
** libs
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c bbox.cpp -o bbox.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal.cpp -o gdal.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_geom.cpp -o gdal_geom.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_read.cpp -o gdal_read.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_utils.cpp -o gdal_utils.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c gdal_write.cpp -o gdal_write.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c geos.cpp -o geos.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c hex.cpp -o hex.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c polygonize.cpp -o polygonize.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c proj.cpp -o proj.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c raster2sf.cpp -o raster2sf.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c sfg.cpp -o sfg.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c signed_area.cpp -o signed_area.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c stars.cpp -o stars.o
g++ -std=gnu++11 -I/usr/share/R/include -DNDEBUG -I/usr/include/gdal -I/usr/local/include -I"/home/james/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c wkb.cpp -o wkb.o
g++ -std=gnu++11 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o sf.so RcppExports.o bbox.o gdal.o gdal_geom.o gdal_read.o gdal_utils.o gdal_write.o geos.o hex.o polygonize.o proj.o raster2sf.o sfg.o signed_area.o stars.o wkb.o -lproj -L/usr/lib -lgdal -L/usr/local/lib -lgeos_c -L/usr/local/lib -lgeos -L/usr/lib/R/lib -lR
installing to /home/james/R/x86_64-pc-linux-gnu-library/3.4/sf/libs
** R
** data
** demo
** inst
** preparing package for lazy loading
in method for âdbWriteTableâ with signature â"PostgreSQLConnection","character","sf"â: no definition for class âPostgreSQLConnectionâ
in method for âdbDataTypeâ with signature â"PostgreSQLConnection","sf"â: no definition for class âPostgreSQLConnectionâ
in method for âcoerceâ with signature â"Spatial","sf"â: no definition for class âSpatialâ
in method for âcoerceâ with signature â"Spatial","sfc"â: no definition for class âSpatialâ
in method for âcoerceâ with signature â"sf","Spatial"â: no definition for class âSpatialâ
in method for âcoerceâ with signature â"sfc","Spatial"â: no definition for class âSpatialâ
in method for âcoerceâ with signature â"XY","Spatial"â: no definition for class âSpatialâ
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
Error: package or namespace load failed for âsfâ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/home/james/R/x86_64-pc-linux-gnu-library/3.4/sf/libs/sf.so':
/home/james/R/x86_64-pc-linux-gnu-library/3.4/sf/libs/sf.so: undefined symbol: GEOSSTRtree_nearest_generic_r
Error: loading failed
Execution halted
ERROR: loading failed
* removing â/home/james/R/x86_64-pc-linux-gnu-library/3.4/sfâ
The downloaded source packages are in
â/tmp/Rtmpj7L70N/downloaded_packagesâ
Warning message:
In install.packages("sf") :
installation of package âsfâ had non-zero exit status
It looks like perhaps it's similar to this issue...?https://github.com/r-spatial/sf/issues/40
To me it looks most like #844; see also the README.md of this repo, paragraph on "Multiple GDAL, GEOS and/or PROJ versions on your system".
Thanks will check those out.
It does indeed look like I have multiple GEOS on my system .
james:-$ locate /bin/geos
/opt/geos/bin/geos-config
/usr/bin/geos-config
/usr/local/bin/geos-config
I'm too novice to understand how to fix this though. Could you point me towards the best place to ask for help please? (as I appreciate this isn't a SF problem).
If removing packages on your system doesn't remove everything, I'm afraid the only thing you can do is remove offending files by hand.
There are a number of docker files that may be helpful creating more controlled systems.
Strange, I've now removed multiple versions of geos but still get the same issue.
james:~$ locate bin/geos
/usr/bin/geos-config
james:~$ locate bin/gdal
/usr/bin/gdal-config
/usr/bin/gdal_contour
/usr/bin/gdal_grid
/usr/bin/gdal_rasterize
/usr/bin/gdal_translate
/usr/bin/gdaladdo
/usr/bin/gdalbuildvrt
/usr/bin/gdaldem
/usr/bin/gdalenhance
/usr/bin/gdalinfo
/usr/bin/gdallocationinfo
/usr/bin/gdalmanage
/usr/bin/gdalserver
/usr/bin/gdalsrsinfo
/usr/bin/gdaltindex
/usr/bin/gdaltransform
/usr/bin/gdalwarp
james:~$ locate bin/proj
/usr/bin/proj
````
Checking versions
james:~$ sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libproj-dev is already the newest version (4.9.2-2).
libudunits2-dev is already the newest version (2.2.20-1).
libgdal-dev is already the newest version (2.2.2+dfsg-1~xenial1).
libgdal-dev set to manually installed.
libgeos-dev is already the newest version (3.5.1-3~xenial0).
libgeos-dev set to manually installed.
0 to upgrade, 0 to newly install, 0 to remove and 15 not to upgrade.
```
You're looking for binaries, where you should be looking for dynamic libraries.
Oh. I don't know how to do that. :-(
I'm very aware that I'm being a drag on your time, so I'm really sorry, but could you advise on how to proceed?
I managed to do this though, maybe it helps?
james:~$ /sbin/ldconfig -p | grep geos
libgeos_c.so.1 (libc6,x86-64) => /usr/local/lib/libgeos_c.so.1
libgeos_c.so.1 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgeos_c.so.1
libgeos_c.so (libc6,x86-64) => /usr/local/lib/libgeos_c.so
libgeos_c.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgeos_c.so
libgeos-3.6.2.so (libc6,x86-64) => /usr/local/lib/libgeos-3.6.2.so
libgeos-3.5.1.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgeos-3.5.1.so
libgeos-3.5.0.so (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgeos-3.5.0.so
I guess the issue is that I have duplicate items on the left of this, pointing at different items on the right. I guess I can delete some of the items on the right?
No, I'm sorry.
Now solved. Uninstalled and reinstalled lots of packages. Not quite sure what did the trick, but rgdal and sf will now install. Thanks for your efforts anyway edzer.
For what it's worth, though I am not sure if this hack is a really good idea. At the moment, I am trying to run QGIS3 on Ubuntu 18.04. At the same time I would like to have rgdal and sf available within R. For the latter I would need to run sudo aptitude install libgdal-dev, unfortunately, this would remove my QGIS3 installation. Therefore, I need to use following GDAL version:
```sh
gdalinfo --version
GDAL 2.2.3, released 2017/11/20
Trying to install **rgdal**, leads to the error message as pointed out by @JimShady at the beginning of this issue.
```r
install.packages("rgdal")
# not all output shown
...
checking for gdal-config... /usr/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 2.2.3
checking GDAL version >= 1.11.4... yes
checking gdal: linking with --libs only... yes
checking GDAL: /usr/share/gdal/2.2/pcs.csv readable... no
configure: error: pcs.csv not found in GDAL data directory.
ERROR: configuration failed for package ârgdalâ
...
Apparently, the pcs.csv table (which can be found in my case under /usr/share/gdal) is required in a folder named /usr/share/gdal/2.2, however, this folder does not exist, therefore, I simply created this folder and copied the required file into it.
sudo mkdir /usr/share/gdal/2.2
sudo cp /usr/share/gdal/pcs.csv /usr/share/gdal/2.2/pcs.csv
This let's you run install.packages("rgdal") successfully in R. To also install sf succesfully, I first needed to install libudunits2 via sudo apt-get install libudunits2-dev, and in R, I needed to set additionally the GDAL_DATA environment variable:
Sys.setenv("GDAL_DATA"="/usr/share/gdal")
install.packages("sf")
Hmm. I also run QGIS3 . I didn't realise the issue was linked to that, but maybe it was.
Are you (both) installing from PPA ubuntugis-unstable, and does QGIS3 also come from there?
This is how I installed QGIS3:
# add QGIS repository for Ubuntu 18.04 to sources.list
sudo sh -c 'echo "deb http://qgis.org/debian bionic main" >> /etc/apt/sources.list'
sudo sh -c 'echo "deb-src http://qgis.org/debian bionic main" >> /etc/apt/sources.list'
sudo sh -c 'echo "deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu bionic main" >> /etc/apt/sources.list'
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
# install aptitude to cleverly solve dependency issues
sudo apt-get install aptitude
sudo aptitude install qgis python-qgis qgis-plugin-grass
The first thing to note is that in the meantime, http://qgis.org/ubuntu is also available, so I should have used this repository instead of http://qgis.org/debian. Not sure if that would have solved the problem already, but I guess not.
Secondly, yes, I am also using PPA ubuntugis-unstable but I haven't installed QGIS from there, but properly should have done so, my apologies! I will try this, i.e., I will replace http://qgis.org/debian by https://qgis.org/ubuntugis (in accordance with the QGIS installation guide). Thanks for the advice.
In the rgdal case, we trust what
GDAL_DATADIR=`${GDAL_CONFIG} --datadir`
returns. If GDAL was installed such that gdal-config returns the wrong value, it really is an upstream issue. I can add a workaround looking for GDAL_DATA if the directory given by gdal-config --datadir fails.
rgdal on R-Forge svn revision 778 package version 1.3-8 now tests for the GDAL_DATA environment variable if the string returned by gdal-config --datadir is not a directory, and if GDAL_DATA is a directory uses that instead of the string returned by gdal-config --datadir. Please do tell upstream packagers to ensure that gdal-config returns correct values, even if the think they know better.
@rsbivand thanks! In fact, gdal-config --datadir returns a path to a non-existing directory, i.e., usr/share/gdal/2.2. I have created a corresponding GDAL issue.
@edzer I have now installed both QGIS3 and GDAL from PPA ubuntugis-unstable. QGIS3 is still using GDAL 2.2.3, hence, the problem persists, but for the time being, I have a work around and sooner or later they will update to GDAL 2.3, I guess. In any case, I wish you both a
Happy New Year!
I too had issues with having QGIS 3.4 and sf installed at the same time, after upgrading Ubuntu from 16.04 to 18.04, getting this error while trying to install sf -
configure: error: pcs.csv not found in GDAL data directory.
The trick suggested by @jannes-m also solved the issue for me -
sudo mkdir /usr/share/gdal/2.2
sudo cp /usr/share/gdal/pcs.csv /usr/share/gdal/2.2/pcs.csv
Please never use tricks. Do feed back upstream to the packager who is having GDAL_DATA (or gdal-config --datadir point to a non-existing directory. I guess that they are trying to versionise the files in GDAL_DATA, but are not succeeding. They have not thought through the consequences of gdal-config --datadir being wrong, and need to do this urgently. Please try to install rgdal from install.packages("rgdal", repos="http://R-Forge.R-project.org") setting the shell variable GDAL_DATA to the correct value first, and report back on whether this is a robust treatment. Otherwise you risk R packages seeing stale GDAL data files splattered in unmaintained places across your system.
@rsbivand I understand, thanks.
I'm using ubuntu 20.04 with R 4.0. New computer so shouldn't be old versions of gdal around. Reading the chain of comments above and the errors that came from trying to install rgdal, sf, etc.. I discovered that there were no copies of pcs.csv on my computer. proj-bin is at version 6.3.1-1, gdalinfo says the version is gdal 3.0.4. I have a mac with a similar set up. It did have copies of pcs.csv. So I copied one to my ubuntu machine and put it in/usr/share/gdal/. I still get failures installing. The error messages involve dbWriteTable. and report double free or corruption (!prev). But thought it might be useful to report the missing pcs.csv file
Most helpful comment
I too had issues with having QGIS 3.4 and
sfinstalled at the same time, after upgrading Ubuntu from 16.04 to 18.04, getting this error while trying to installsf-The trick suggested by @jannes-m also solved the issue for me -