问题
I had the sf package installed and working on r 3.4.3 on Centos 7. It was complicated to get the right version of GDAL but it was working and I was able to use tidycensus to make maps.
However when I upgraded to R 3.5 and then attempted to upgrade or reinstall sf, I started getting this message:
checking for gdal-config...
/bin/gdal-config checking gdal-config usability... yes
configure: GDAL: 1.11.4 checking GDAL version >= 2.0.0... no
configure: error: sf is not compatible with GDAL versions below 2.0.0
However I definitely have GDAL 2 installed as evidenced by the fact that it was working before plus if I do gdalinfo --version
I get
GDAL 2.2.3, released 2017/11/20
I did read a lot of SO questions and discovered the RDGAL is compiled with the 1.11.4 version and I think that sf relies on that. However I have not found a way on Centos to force it to use GDAL 2.2.3. I have removed and reinstalled rdgal and it didn't help, it always reinstalls with 1.1.
rgdal::getGDALVersionInfo(str = "--version")
回答1:
Well I'm not totally sure if this was the whole solution but following the comments on this page I did this:
R CMD INSTALL -l ~/R/x86_64-redhat-linux-gnu-library/3.1
--configure-args='
--with-gdal-config path/to/software/dir/bin/gdal-config
--with-proj-include path/to/software/dir/include
--with-proj-lib path/to/software/dir/lib
--with-proj-data path/to/software/dir/share/proj
--with-data-copy=yes' rgdal
And it worked. I did other things in between that may have helped though.
Update: Going through the same thing with an updated R to 3.6, I found that if I removed rgdal and reinstalled (with no special options) I was able to then install sf successfully.
来源:https://stackoverflow.com/questions/51210587/sf-on-r-3-5-cant-find-correct-version-of-gdal