Skip to content

geocompx/docker

Repository files navigation

Geocomputation with Docker

This repo provides Docker images for geographic research and reproducing code from the books Geocomputation with R and Geocomputation with Python, building on the Rocker Project.

# Latest rocker/geospatial + geocompr dependencies
docker run -e PASSWORD=pw --rm -p 8786:8787 ghcr.io/geocompx/latest
# With up-to-date OSGeo packages and qgisprocess:
docker run -e PASSWORD=pw --rm -p 8786:8787 ghcr.io/geocompx/osgeo

Log in at http://localhost:8786/ with username rstudio and the password from the command (e.g. pw).

# Shell-only, no RStudio:
docker run -e PASSWORD=pw --rm -ti ghcr.io/geocompx/latest /bin/bash
# Bind-mount your working directory:
docker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data -e PASSWORD=pw ghcr.io/geocompx/minimal
# Pin a specific version (date tag):
docker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data -e PASSWORD=pw ghcr.io/geocompx/minimal:date_2024-10-14

Devcontainers and VS Code support

The R-enabled images (latest, minimal, osgeo, pythonr) support VS Code Devcontainers. Open the repo in VS Code and it will detect the .devcontainer/devcontainer.json configuration automatically.

Versions

The base image is rocker/geospatial from rocker-versioned2. We provide variants with different package sets and library versions:

Image Command Size Description
minimal-slim docker pull ghcr.io/geocompx/minimal-slim ? Slim R + geospatial without RStudio
python docker pull ghcr.io/geocompx/python 2.32GB Python + geospatial libraries
pythonr docker pull ghcr.io/geocompx/pythonr 4.37GB Python + R + geospatial libraries
minimal docker pull ghcr.io/geocompx/minimal 5.43GB Lightweight R + core geospatial libs
suggests docker pull ghcr.io/geocompx/suggests 5.67GB Full R dependencies for geocompx
latest docker pull ghcr.io/geocompx/latest 5.70GB Default full geocompx environment
osgeo docker pull ghcr.io/geocompx/osgeo 6.07GB R with latest OSGeo GDAL/PROJ/GEOS
buildbook docker pull ghcr.io/geocompx/buildbook 6.44GB Pre-configured book build environment
rocker-rpy docker pull ghcr.io/geocompx/rocker-rpy 6.46GB R + Python scientific stack
rust docker pull ghcr.io/geocompx/rust 7.63GB R + Rust toolchain
rocker-rpyjl docker pull ghcr.io/geocompx/rocker-rpyjl 7.68GB R + Python + Julia multi-language
qgis docker pull ghcr.io/geocompx/qgis 8.63GB QGIS desktop GIS environment

Add :tagname after ghcr.io/geocompx/<image> for a specific version (see packages).

Building leaner custom images

For users who want smaller images or different packages, a reference minimal-slim/Dockerfile shows how to build from rocker/r-ver without RStudio or heavy CLI tools, using rocker-versioned2 scripts:

FROM rocker/r-ver:4.6.0
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgdal-dev libgeos-dev libproj-dev \
    && rm -rf /var/lib/apt/lists/*
RUN install2.r sf terra spData

Available rocker-versioned2 scripts: - install_geospatial.sh — GDAL, PROJ, GEOS + sf, terra, raster, stars, sp - install_rstudio.sh — RStudio Server with S6 supervisor - install_python.sh — Python 3 + reticulate - install_tidyverse.sh — Tidyverse stack - install_quarto.sh — Quarto CLI

Examples

Python

The python image provides Python geospatial packages (pandas, geopandas, movingpandas, osmnx, matplotlib, shapely, seaborn). The pythonr image adds R on top.

docker pull ghcr.io/geocompx/python
docker run -e PASSWORD=pw --rm -ti ghcr.io/geocompx/python /bin/bash
python3 -c "import geopandas; print(geopandas.__version__)"

For R + Python interop, run ghcr.io/geocompx/pythonr and use reticulate from R.

QGIS

The qgis image includes QGIS, GRASS, and SAGA.

docker run --rm -ti ghcr.io/geocompx/qgis /bin/bash
qgis --version

QGIS algorithms are accessible from R via qgisprocess:

pak::pak("paleolimbot/qgisprocess")
qgis_algs = qgisprocess::qgis_algorithms()
nrow(qgis_algs)
table(qgis_algs$provider)

With GRASS and SAGA available as providers, you have access to ~970 algorithms.

osgeo

For testing against recent GDAL/PROJ/GEOS versions:

docker run -d -p 8786:8787 -v $(pwd):/home/rstudio/data \
  -e USERID=$UID -e PASSWORD=pw ghcr.io/geocompx/osgeo

Building the images locally

docker build qgis -t geocompx/qgis
docker build minimal -t geocompx/minimal

Using GitHub PAT with BuildKit secret mounts

Some images (suggests, rust) install packages from GitHub repositories. Pass a GitHub PAT securely with BuildKit:

echo "your_github_token" > GITHUB_PAT.txt
DOCKER_BUILDKIT=1 docker build --secret id=GITHUB_PAT,src=GITHUB_PAT.txt -t geocompx/suggests suggests

About

Docker images for reproducible Geocomputation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

 
 
 

Contributors