Installing GDAL on Uberspace 7

I was pleasantly surprised to find out that Uberspace π now has lots of precompiled extensions for PostgreSQL π. And among them is PostGIS πΊοΈ! There’s also a dedicated section in the installation manual. That’s pretty handy, if you want to store spatial data in your database. But how do you import spatial data? You can’t always rely on shp2pgsql
. We need some proper ogr2ogr
. We need GDAL!
Here are the steps to install GDAL on Uberspace 7. This is heavily based on Alex Bilz' tutorial, but updated for recent versions, especially of Proj and GDAL itself.
Get current CMAKE
As of writing this post, Uberspace hosts a relatively old version of CMAKE (2.8.x), but in order to compile Proj and GDAL, we need at least version 3.4.
wget https://github.com/Kitware/CMake/releases/download/v3.17.3/cmake-3.17.3-Linux-x86_64.sh
bash cmake-3.17.3-Linux-x86_64.sh --skip-license --prefix=$HOME
rm cmake-3.17.3-Linux-x86_64.sh
hash -r
# Test
cmake --version
cmake version 3.17.3
Install GEOS
mkdir geos && cd geos
curl -O http://download.osgeo.org/geos/geos-3.11.1.tar.bz2
tar -vxf geos-3.11.1.tar.bz2
cd geos-3.11.1
./configure --prefix=$HOME/opt/geos/build --enable-python
make && make install
# Test
opt/geos/build/bin/geos-config --version
3.11.1
Install Proj
cd ~
mkdir proj && cd proj
curl -O http://download.osgeo.org/proj/proj-9.1.1.tar.gz
tar -vxf proj-9.1.1.tar.gz
cd proj-9.1.1
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/opt/proj
cmake --build .
cmake --build . --target install
# Test
opt/proj/bin/proj
Rel. 9.1.1, December 1st, 2022
Note: I ran into trouble while compiling Proj, or, to be more precise: I ran out of memory. If you see that the compiling process gets killed, you probably need to disable some currently running processes using supervisorctl stop
.
GDAL
cd ~
mkdir gdal && cd gdal
curl -O http://download.osgeo.org/gdal/3.6.2/gdal-3.6.2.tar.gz
tar -xvf gdal-3.6.2.tar.gz
cd gdal-3.6.2
mkdir build && cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX=$HOME/opt/gdal \
-DGDAL_SET_INSTALL_RELATIVE_RPATH=ON \
-DPROJ_INCLUDE_DIR=$HOME/opt/proj/include \
-DPROJ_LIBRARY_RELEASE=$HOME/opt/proj/lib64/libproj.so \
-DGEOS_INCLUDE_DIR=$HOME/opt/geos/build/include \
-DGEOS_LIBRARY=$HOME/opt/geos/build/lib64/libgeos_c.so \
-DGDAL_USE_POSTGRESQL=ON
Adapt environment variables
I needed to change the LD_LIBRARY_PATH
environment variable so that it picks up Proj’s lib files. Just make a couple of adjustments to your .bash_profile
.
vi ~/.bash_profile
PROJ_DATA=/home/chringel/opt/proj/lib64/
export PROJ_DATA
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PROJ_DATA
export LD_LIBRARY_PATH
source ~/.bash_profile
Test
opt/gdal/bin/gdalinfo --version
GDAL 3.6.2, released 2023/01/02 (debug build)
Cleanup
That was a lot of source files. Time to remove them!
rm -rf ~/geos ~/proj ~/gdal