- Prerequisites
- Install key packages
- Getting started with tools for geocomputation
- Other tools for boosting productivity and developer experience
- Alternative projects
Inspired by a post on installing commonly needed GIS software on Ubuntu and having recently got a new computer (an Entroware Proteus, a bit faster than the second hand Lenovo laptop I was running when I created this repo!) with Ubuntu freshly installed, I decided to make the process of installing GIS software on it as reproducible as possible. After installing this software your computer may look a bit like this:
Clutter for demo purposes!
This is not intended to replace the excellent OSGeo Live distro, which contains a ton of amazing geo packages. Instead it’s for people who want lean, core GIS functionality on their existing Ubuntu machine, with a focus on geocomputation and data science.
Rather than providing automated scripts, it simply provides the bash commands here in the README for you to copy, paste (or Ctrl+Shift+Enter if in RStudio if you download this README, a great shortcut) Core programs it shows how to install are:
- GitHub’s CLI tool for command-line collaboration and code sharing
- R with access to pre-compiled packages, a powerhouse for statistical computing
- R packages for working with spatial data
- RStudio, a space-aged editor for R
- VS Code with extensions for R, Python, C/C++, Rust, Docker, and more
- Docker, which gives ultimate power and flexibility to install and run software
- QGIS, probably the most popular GUI-driven GIS in the world
- Recent versions of GDAL and GEOS C/C++ libraries
- Python packages for Geographic Data Science
- Rust, an upcoming systems language with impressive geo libs
All this can be a pain to install manually. The commands below are designed to make your life easier. Any comments/suggestions: welcome
- A working installation of Ubuntu 22.04, ‘Jammy Jellyfish’ on a computer you have access to
Fire up a terminal, e.g. with Ctl-Alt-T
after booting Ubuntu, then
enter the following.
GitHub has developed a command line interface (CLI) tool for enabling fast and intuitive interaction with the world’s premier code hosting platform. It’s a good place to start because it’s small, self-contained, and can be used to clone code repos like this one. Install it with the following cryptic commands from the project’s GitHub page:
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
Test to see if it works as follows:
# Log-in to GitHub from the command line
gh auth login
gh repo clone Robinlovelace/install-geocomp-ubuntu
cd install-geocomp-ubuntu
less README.md
You may also want to update your Git version, which is installed by default on Ubuntu:
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
Previously I was on Git 2.25.1, now I’m on 2.40.0:
git --version
git version 2.43.2
Setup git with the following commands
git config --global user.email "[email protected]"
git config --global user.name "trachelium"
# Set the default branch to main:
git config --global init.defaultBranch main
I have become a huge fan of VS Code and installing it plus some amazing extensions is covered in the next section. VS Code is increasingly good with decent support for visualisations and, as the screenshot below shows, even now marks-up markdown outputs from Quarto documents. However, if you want to do standard data science things and create reproducible documents, R+RStudio is hard to beat, especially if you’re just starting out with data science. Install them with the following commands:
These instructions were adapted from https://rtask.thinkr.fr/installation-of-r-4-2-on-ubuntu-22-04-lts-and-tips-for-spatial-packages/
sudo apt update
sudo apt upgrade
sudo apt install -y --no-install-recommends software-properties-common dirmngr
# Add the keys
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
# You'll be asked to choose your geographical area
sudo apt install -y r-base r-base-core r-recommended r-base-dev
# Install PPA with pre-compiled packages
sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+
A difference between R packages on Windows and Ubuntu is that by default
Windows always installs binary versions of packages, meaning no
compilation time. To speed-up installation of R packages you can add an
Ubuntu repo that will allow you to install pre-compiled packages from
the system command line. Although there are projects like
r2u that give you binary packages
with install.packages()
I prefer the control of using the system
command line for binaries and the R console for installing packages that
want to be compiled, to avoid issues like this:
rocker-org/rocker-versioned2#631
Get a load of great R packages with the following commands:
# My own selection among 5000...
sudo apt install -y r-cran-rgl r-cran-rjags r-cran-snow r-cran-ggplot2 r-cran-igraph r-cran-lme4 r-cran-rjava r-cran-devtools r-cran-roxygen2 r-cran-rjava
sudo apt install r-cran-tidyverse
sudo apt install r-cran-sf r-cran-tmap r-cran-osmextract r-cran-mapview
# System deps for cartography
sudo apt install -y libgdal-dev libproj-dev libgeos-dev libudunits2-dev libv8-dev libnode-dev libcairo2-dev libnetcdf-dev
sudo apt install -y libglu1-mesa-dev freeglut3-dev mesa-common-dev
# Extra packages for image manipulation
sudo apt install -y libmagick++-dev libjq-dev libv8-dev libprotobuf-dev protobuf-compiler libsodium-dev imagemagick libgit2-dev
# rspatial
sudo apt install r-cran-sf r-cran-terra r-cran-mapedit r-cran-tmap r-cran-mapdeck r-cran-shinyjs
Rscript -e 'install.packages("languageserver")'
RStudio: https://www.entroware.com/store/proteus
wget https://download1.rstudio.org/electron/jammy/amd64/rstudio-2023.03.0-386-amd64.deb
sudo dpkg -i rstudio*
rm -v rstudio*
After installing RStudio you can open it by pressing the ‘Windows button’ and they typing RStudio. You should also be able to open it with the following command in the terminal:
rstudio
After opening RStudio you can open the folder containing these instructions, or any folder, with the following command typed into the R console.
rstudioapi::openProject("~/Download/install-geocomp-ubuntu/")
Also in RStudio you can commit and push changes to this or any repo as
follows, starting by opening a terminal by clicking on the Terminal
button or by typing the shortcut: Alt+Shift+M
. You can also execute
lines of code from the source editor in RStudio in the terminal by
typing Ctrl+Alt+Enter
, which will send the current line of code to the
terminal.
git status
git commit -am 'Update instructions with info on using RStudio'
VS Code is a versatile and future-proof IDE.
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
rm packages.microsoft.gpg
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
sudo apt-get install code
code --install-extension ms-vscode-remote.remote-containers
# Install the Python extension:
code --install-extension ms-python.python
# Remote containers:
code --install-extension ms-vscode-remote.remote-containers
# Install ritwickdey.LiveServer:
code --install-extension ritwickdey.LiveServer
A great feature of VS Code is that you can execute bash commands in the
integrated terminal. Open the integrated terminal by typing the
shortcut: Ctrl+J
. Open a new terminal in VS code by typing the
shortcut: Ctrl+backtick
(`).
Executing code is made even easier by the Quarto extension for VS Code, which can be installed as follows from bash:
code --install-extension quarto.quarto
After that extension has been installed you should be able to execute
code in the integrated terminal by typing Ctrl+Enter
in the source
editor, as shown in the following screenshot:
code --install-extension reditorsupport.r
code --install-extension github.copilot
Install the Quarto command line tool:
wget "https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.553/quarto-1.4.553-linux-amd64.deb" -O /tmp/quarto.deb
sudo dpkg -i /tmp/quarto.deb
Install the Quarto R package:
Rscript -e "remotes::install_github('quarto-dev/quarto-r')"
VS Code has a nice feature that enables you to develop inside a ‘devcontainer’. Devcontainers rely on Docker, which can be installed as follows:
Docker is a system platform that allows you to run applications in isolated environments called containers. Containers are similar to virtual machines, but they are more lightweight and efficient.
Docker allows you to run applications in a sandboxed environment, which is useful for reproducibility and security. In essence: run anything, anywhere.
Following instructions from https://docs.docker.com/engine/install/ubuntu/, first install the dependencies:
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Then follow these commands:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Use the following command to set up the repository:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Install Docker Engine
# Update the apt package index, and install the latest version of Docker Engine, containerd, and Docker Compose, or go to the next step to install a specific version:
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
The following steps enable you to run docker without sudo
. As outlined
at https://docs.docker.com/engine/install/linux-postinstall/ this does
have security implications so it may be unwise to run these commands on
important production servers or critical infrastructure. For a personal
laptop that does not contain sensitive information the risks are low.
sudo groupadd docker
# Add your user to the docker group:
sudo usermod -aG docker $USER
# Log out and log back in so that your group membership is re-evaluated.
# If you’re running Linux in a virtual machine, it may be necessary to restart the virtual machine for changes to take effect.
# You can also run the following command to activate the changes to groups:
newgrp docker
# Verify that you can run docker commands without sudo.
docker run hello-world
# If you initially ran Docker CLI commands using sudo before adding your user to the docker group, you may see the following error:
# WARNING: Error loading config file: /home/user/.docker/config.json -
# stat /home/user/.docker/config.json: permission denied
# This error indicates that the permission settings for the ~/.docker/ directory are incorrect, due to having used the sudo command earlier.
# To fix this problem, either remove the ~/.docker/ directory (it’s recreated automatically, but any custom settings are lost), or change its ownership and permissions using the following commands:
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -R
To check your code
and docker
installations worked you can try to
reproduce Geocomputation with Python:
gh repo clone geocompx/geocompy
code geocompy
If you installed the remote-containers
extension successfully, you
should see a button with “Reopen in Container” in the bottom right of VS
Code.
Click that button and you’ll see the devcontainer launch. If it works, you can try reproducing the entirety of the book from the command line with the following inside VS Code (you can launch the terminal by pressing Ctrl+J`):
quarto preview
If you see something like this, congratulations, you can develop almost anything in reproducible and easy-to-use devcontainers!
The following launches a docker container with JupyterLab:
docker run -it --rm \
-p 8888:8888 \
-u root \
-v "${PWD}/jupyterlab-jovyan":/home/jovyan \
-e NB_UID=$(id -u) \
-e NB_GID=$(id -g) \
-e CHOWN_HOME=yes \
-e CHOWN_HOME_OPTS='-R' \
glcr.b-data.ch/jupyterlab/r/geospatial
From: https://github.com/geocompx/docker/blob/master/qgis/Dockerfile
# To use the qgis archive you have to first add the archive’s repository public key:
wget https://download.qgis.org/downloads/qgis-archive-keyring.gpg
gpg --no-default-keyring --keyring ./qgis-archive-keyring.gpg --list-keys
# After you have verified the output you can install the key with:
sudo mkdir -m755 -p /etc/apt/keyrings # not needed since apt version 2.4.0 like Debian 12 and Ubuntu 22 or newer
sudo cp qgis-archive-keyring.gpg /etc/apt/keyrings/qgis-archive-keyring.gpg
# Alternatively you can download the key directly without manual verification:
# Types: deb deb-src
# URIs: *repository*
# Suites: *codename*
# Architectures: amd64
# Components: main
# Signed-By: /etc/apt/keyrings/qgis-archive-keyring.gpg
# With the keyring in place you can add the repository as /etc/apt/sources.list.d/qgis.sources with following content:
# Types: deb deb-src
# URIs: https://qgis.org/ubuntu-ltr
# Suites: jammy
# Architectures: amd64
# Components: main
# Signed-By: /etc/apt/keyrings/qgis-archive-keyring.gpg
sudo vim /etc/apt/sources.list.d/qgis.sources
# After that type the commands below to install QGIS:
sudo apt update
sudo apt install qgis qgis-plugin-grass
# In case you would like to install QGIS Server, type:
sudo apt install qgis-server --no-install-recommends --no-install-suggests
# if you want to install server Python plugins
sudo apt install python3-qgis
sudo apt-get update
sudo apt-get -y --with-new-pkgs upgrade && \
sudo apt-get -y autoremove && \
sudo apt-get -y install qgis qgis-plugin-grass saga
# for how to use the qgis-plugin-manager, see https://github.com/3liz/qgis-plugin-manager
pip3 install qgis-plugin-manager
# to enable the qgis-plugin-manager, add the corresponding path to PATH
# ENV PATH="/home/rstudio/.local/bin:$PATH"
echo "export PATH=\"/home/rstudio/.local/bin:\$PATH\"" >> /etc/profile
# from the next line onwards we have trouble with the rstudio server, therefore we switch to the rstudio user
mkdir -p /home/rstudio/.local/share/QGIS/QGIS3/profiles/default/python/plugins
ENV QGIS_PLUGINPATH=/home/rstudio/.local/share/QGIS/QGIS3/profiles/default/python/plugins
echo 'export QGIS_PLUGINPATH=/home/rstudio/.local/share/QGIS/QGIS3/profiles/default/python/plugins' >> /etc/profile
less /etc/profile
exit
qgis-plugin-manager init
qgis-plugin-manager update
# install SAGA next generation plugin
qgis-plugin-manager install 'Processing Saga NextGen Provider'
Rscript -e "install.packages('remotes')"
Rscript -e "remotes::install_github('r-spatial/qgisprocess')"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Make Rust available:
source "$HOME/.cargo/env"
# Try installing a crate:
cargo install geo
cargo install geozero
cargo install zonebuilder
Once you have the software installed, you can run it as follows:
- For QGIS, you can launch it with the usual launcher or from the command line
qgis # run QGIS
See the QGIS manual
- For R, you can run R from the bash shell by entering
R
. For beginners, RStudio is recommended, which can be opened from the Ubuntu Dash launcher or from bash with:
rstudio
These are some fast and versatile command-line utilities that provide an alternitive to standard Unix tools.
ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern. It is similar to other popular search tools like The Silver Searcher, ack, and grep.
sudo apt install ripgrep
rg --help
fd is a simple, fast and user-friendly alternative to find.
sudo apt install fd-find
fdfind --help
sd is a find & replace CLI (command-line interface) tool that allows you to perform simple find & replace operations on files.
cargo install sd
sd --help
exa is a modern replacement for ls. It supports colors, file icons, git integration, and more.
cargo install exa
exa .
dust is a more intuitive version of du in rust. It provides a better way to navigate through your system and view disk usage.
cargo install du-dust
dust --help
ripgrep_all is a tool that combines the power of ripgrep for all file formats.
apt install build-essential pandoc poppler-utils ffmpeg ripgrep cargo
cargo install --locked ripgrep_all
sudo add-apt-repository ppa:hluk/copyq
This command adds the PPA maintained by the CopyQ developer Lukas Holecek to your system’s software sources. You’ll be prompted to enter your password to confirm the command.
Update the package list by running the following command:
sudo apt update
Install CopyQ by running the following command:
sudo apt install copyq
This command installs the latest version of CopyQ and its dependencies on your system.
Once the installation is complete, you can launch CopyQ by typing copyq in the terminal or by searching for it in the Applications menu.
Intuitive and time-saving management of AppImages.
sudo add-apt-repository ppa:appimagelauncher-team/stable
sudo apt update
sudo apt install appimagelauncher
LogSeq is an application for storing notes, todo lists, and more. To install it just click on the latest ‘.AppImage’ file in the latest releases, download it, and it should be integrated by AppImage Launcher: https://github.com/logseq/logseq/releases
wget -O zotero.tar.bz2 'https://www.zotero.org/download/client/dl?channel=release&platform=linux-x86_64'
tar -xjf zotero.tar.bz2 -C ~/Downloads/
sudo mv ~/Downloads/Zotero_linux-x86_64 /opt/Zotero
sudo ln -s /opt/Zotero/zotero /usr/local/bin/
sudo apt-get install libdbus-glib-1-2 libgtk-3-0 libxt6 libxrender1 libx11-xcb1
Run Zotero with:
zotero
cd /usr/share/applications
sudo bash -c 'echo "[Desktop Entry]
Version=1.0
Name=Zotero
GenericName=Reference Manager
Comment=Zotero Reference Manager
Exec=/opt/Zotero/zotero %U
Terminal=false
Type=Application
Icon=/opt/Zotero/chrome/icons/default/default256.png
Categories=Office;" > zotero.desktop'
sudo chmod +x zotero.desktop
cd -
ddterm is top down terminal: https://github.com/ddterm/gnome-shell-extension-ddterm I have long been a fan of Guake, the popular terminal emulator based roughly on Quake’s top down terminal. Unfortunately, Guake does not have great support for Wayland, Ubuntu 22.04’s display system, as discussed in this issue that is still open despite being a priority that was opened in 2015: Guake/guake#492
Install it as follows:
cd ~/Downloads/
wget https://github.com/ddterm/gnome-shell-extension-ddterm/releases/download/v43/[email protected]
gnome-extensions install -f ~/Downloads/[email protected]
sudo reboot # you may need to reboot the computer to use it
gnome-extensions enable [email protected]
Signal is an app for messaging and more.
# NOTE: These instructions only work for 64 bit Debian-based
# Linux distributions such as Ubuntu, Mint etc.
# 1. Install our official public software signing key
wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg
cat signal-desktop-keyring.gpg | sudo tee -a /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null
# 2. Add our repository to your list of repositories
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' |\
sudo tee -a /etc/apt/sources.list.d/signal-xenial.list
# 3. Update your package database and install signal
sudo apt update && sudo apt install signal-desktop
Flameshot is a powerful yet simple to use screenshot software.
sudo apt install flameshot
# Add the Google Chrome repository to your system
echo "Adding Google Chrome repository..."
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
# Update your package list
echo "Updating package list..."
sudo apt-get update
# Install Google Chrome
echo "Installing Google Chrome..."
sudo apt-get install google-chrome-stable -y
echo "Google Chrome installation complete."
# Add the Microsoft Edge repository to your system
echo "Adding Microsoft Edge repository..."
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.asc.gpg
sudo install -o root -g root -m 644 microsoft.asc.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
rm microsoft.asc.gpg
# Update your package list
echo "Updating package list..."
sudo apt-get update
# Install Microsoft Edge
echo "Installing Microsoft Edge..."
sudo apt-get install microsoft-edge-dev -y
echo "Microsoft Edge installation complete."
sudo apt install openjdk-19-jdk
mkdir ~/programs
wget https://github.com/DaveJarvis/kmcaster/releases/latest/download/kmcaster.jar -O ~/programs/kmcaster.jar
java -jar ~/programs/kmcaster.jar -h
java -jar ~/programs/kmcaster.jar -d 70
Syncthing is a great way to synchronize laptops, phones and other devices. I use it for syncing photos onto my laptop and into family photo albums, as shown below.
# Add Syncthing repository key
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -
# Add Syncthing repository to system sources
echo "deb https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
# Update system package cache
sudo apt-get update
# Install Syncthing package
sudo apt-get install syncthing -y
# Start the Syncthing service and enable it to run at system boot time
syncthing
# Output installation completed message
echo "Syncthing installation completed successfully!"
rclone
is a tool for copying and syncing files between computers. It
offers several advantages over rsync, including:
-
Support for more cloud storage providers: Rclone supports a wide range of cloud storage providers, including Dropbox, Google Drive, Amazon S3, Microsoft OneDrive, Box, among others. In contrast, rsync only supports local, networked, or remote file transfer.
-
Encryption and compression: Rclone supports several encryption methods and compression algorithms to secure and reduce the size of data during transfer. Rsynd doesn’t have native support for encryption and compression.
-
Synchronization: Rclone has a built-in synchronization tool that allows you to keep your files and directories in sync across different storage locations. While rsync can be used for synchronization, it requires a bit more setup and configuration.
-
Multi-threaded transfers: Rclone can upload and download files using multiple threads simultaneously, which can significantly speed up the transfer process. Rsynce is limited to single-threaded transfers.
-
Cross-platform compatibility: Rclone is a cross-platform tool that can be run on Windows, Linux, macOS, and other operating systems. Rsync, on the other hand, is primarily a Unix-based tool and may require additional setup on non-Unix systems.
Install it with:
sudo apt install rclone
Install the screenshare-to-GIF tool Peak with the following commands on Ubuntu:
# Install simple screen recorder on ubuntu:
sudo apt install simplescreenrecorder
Download discord from https://discord.com/download and install it with:
sudo apt install libgconf-2-4 libc++1
sudo dpkg -i discord.deb
sudo snap install slack --classic
https://github.com/abraunegg/onedrive/blob/master/docs/ubuntu-package-install.md
rm -rf /var/lib/dpkg/lock-frontend
rm -rf /var/lib/dpkg/lock
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get autoremove -y
apt-get autoclean -y
wget -qO - https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_22.04/Release.key | gpg --dearmor | sudo tee /usr/share/keyrings/obs-onedrive.gpg > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/obs-onedrive.gpg] https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_22.04/ ./" | sudo tee /etc/apt/sources.list.d/onedrive.list
sudo apt-get update
# Step 4: Install 'onedrive'
# Run:
sudo apt install --no-install-recommends --no-install-suggests onedrive
sudo apt install gdebi
wget https://download.onlyoffice.com/install/desktop/editors/linux/onlyoffice-desktopeditors_amd64.deb
sudo dpkg -i onlyoffice-desktopeditors_amd64.deb
It’s good practice to keep your home directory on a separate partition.
See here for instructions on how to do that.