Sf: Issue installing sf on Ubuntu with GDAL 3.2?

Created on 7 Dec 2020  路  8Comments  路  Source: r-spatial/sf

I'm working on testing COG endpoints and would like to try stars against a COG with GDAL... at v3.1, GDAL keeps trying to access a COG as an OPeNDAP endpoint so I figured I'd try getting updated to 3.2 as they introduced the ability to specify the format. (not sure sf actually passes the parmeter, but figured it was worth a shot!)

In the process, I found that I can't get sf to install cleanly on this setup. See the Dockerfile below. It makes it all the way to the end then fails with an error I don't see any reference to.

Any ideas? Error is: undefined symbol: proj_get_units_from_database

#10 116.3 ** testing if installed package can be loaded from temporary location
#10 116.7 Error: package or namespace load failed for 'sf' in dyn.load(file, DLLpath = DLLpath, ...):
#10 116.7  unable to load shared object '/usr/local/lib/R/site-library/00LOCK-sf/00new/sf/libs/sf.so':
#10 116.7   /usr/local/lib/R/site-library/00LOCK-sf/00new/sf/libs/sf.so: undefined symbol: proj_get_units_from_database
#10 116.7 Error: loading failed
#10 116.7 Execution halted
#10 116.7 ERROR: loading failed
#10 116.7 * removing '/usr/local/lib/R/site-library/sf'
#10 117.0 Error: Failed to install 'sf' from GitHub:
#10 117.0   (converted from warning) installation of package '/tmp/RtmpdTmy6P/file827502b72/sf_0.9-7.tar.gz' had non-zero exit status
#10 117.0 Execution halted
ARG BASE_CONTAINER=osgeo/gdal:ubuntu-full-3.2.0

FROM ${BASE_CONTAINER}

USER root

RUN apt-get update \
    && apt-get install -y \
    software-properties-common

RUN add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0"

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        littler \
        r-base \
        r-base-dev \
        r-recommended

RUN apt-get install -y libcurl4-openssl-dev libssl-dev libxml2-dev \
    libudunits2-dev libproj-dev libgeos-dev

RUN Rscript -e 'install.packages("devtools")'

RUN Rscript -e 'devtools::install_github("r-spatial/sf")'

Most helpful comment

Hi @dblodgett-usgs, definitely a good question and one that has confused many people. I suggest using the rocker/geospatial:dev-osgeo container, e.g. as follows:

docker run --rm -ti rocker/geospatial:dev-osgeo R -e "library(sf)"

Running that gives:

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(sf)
Linking to GEOS 3.8.1, GDAL 3.2.0, PROJ 7.2.0
> 
> 

See https://github.com/rocker-org/geospatial/issues/31 and the rocker documentation for further info. Does that help? Hope so!

All 8 comments

We saw this problem in https://github.com/rocker-org/geospatial/issues/31 . sf is being tricked into believing PROJ 7.2.0 is available, which kind of it is, in /usr/local/, but this is an instrumented version (I believe) to only serve GDAL and not stand in the way of applications linking to the other PROJ (in /usr/, 6.3.x). So the configure step makes sf believe 7.2.0 is there, but the link step doesn't resolve the symbols (as the /usr/local/lib/libproj*so renamed them to cater GDAL).

My suggestions are either to not build on osgeo:gdal images, or maybe install PROJ 7.2.0 properly on it in /usr/ (you'll probably break GDAL if you overwrite PROJ in /usr/local without renamed symbols). Why *#$ does this image have PROJ 6.3.0 in /usr?

oh wow. OK thanks for the thorough explanation! I'll look for another way to get GDAL 3.2 for experimentation. Looks like https://github.com/perrygeo/docker-gdal-base has it.

Nope, same deal over there. sigh. One day, this proj transition will settle down.

@Robinlovelace what do you suggest?

Hi @dblodgett-usgs, definitely a good question and one that has confused many people. I suggest using the rocker/geospatial:dev-osgeo container, e.g. as follows:

docker run --rm -ti rocker/geospatial:dev-osgeo R -e "library(sf)"

Running that gives:

R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(sf)
Linking to GEOS 3.8.1, GDAL 3.2.0, PROJ 7.2.0
> 
> 

See https://github.com/rocker-org/geospatial/issues/31 and the rocker documentation for further info. Does that help? Hope so!

Nice! I'll give it a go. Thank you.

I did get this working and have been able to test a COG file from stars. Very cool that we will have access to this out of the box on GDAL 3.2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kendonB picture kendonB  路  4Comments

jmsigner picture jmsigner  路  4Comments

dkyleward picture dkyleward  路  4Comments

dpprdan picture dpprdan  路  4Comments

adrfantini picture adrfantini  路  4Comments