Search code examples
rubuntucondagdal

sf R package "is not compatible with GDAL versions below 2.0.0" after installing gdal 2.3 from conda


In trying to install the sf R package, I got the error message:

checking GDAL version >= 2.0.0... no
configure: error: sf is not compatible with GDAL versions below 2.0.0

I then installed gdal 2.3.1 from conda and confirmed the version:

gdalinfo --version

GDAL 2.3.1, released 2018/06/22

But I still get the same error message.

SF on R 3.5 can't find correct version of gdal looks similar but their solution involved installing outside of conda. I'm on Ubuntu.

How can I get sf to recognize the correct version of gdal I have installed?

Edit: sessionInfo() in R shows:

R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.4 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1

I had another issue when installing R from conda

Edit: When installing R from conda via conda install -c r r, I got this error:

-----Error: libudunits2.a not found-----
     If the udunits2 library is installed in a non-standard location,
     use --configure-args='--with-udunits2-lib=/usr/local/lib' for example,
     or --configure-args='--with-udunits2-include=/usr/include/udunits2'
     replacing paths with appropriate values for your installation.
     You can alternatively use the UDUNITS2_INCLUDE and UDUNITS2_LIB
     environment variables.
     If udunits2 is not installed, please install it.
     It is required for this package.

This was still the case after installing udunits and udunits2 from conda:

conda install -c conda-forge udunits
conda install -c conda-forge udunits2

Solution

  • Errors are caused by non-conda package installations. From a clean environment, the sf package can be installed directly from conda:

    conda create -n rsf -c conda-forge r-sf
    source activate rsf
    

    Or from a clean environment:

    conda install -c conda-forge r-sf