Advanced installation of GeoNode on Ubuntu

Mattia Giupponi
5 min readSep 18, 2021

Let’s find an easy way to install GeoNode on our local machine

Photo by Capturing the human heart. on Unsplash

For those who don't know, GeoNode is an Open Source Geospatial content management system (written in Django) designed to be extendible and modifiable.

From the official website, GeoNode is described as follow:

GeoNode is a web-based application and platform for developing geospatial information systems (GIS) and for deploying spatial data infrastructures (SDI). It is designed to be extended and modified, and can be integrated into existing platforms.

Now that we have an overview of what GeoNode is, let’s start with the installation.

Prerequisites:

Before starting, make sure that you have the following programs installed on your machine:

  • Python ≥ 3.7 and VirtualEnv or MiniConda
  • Java OpenJDK (in this tutorial for example I have the v11.0.11)
  • vim or nano
  • git

Step 1: update ubuntu environment

As usual, it’s always better to update our ubuntu environment and add the ubuntugispackage to our repositories. So open a command line and run the following commands:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt update -y; sudo apt upgrade -y;

Step 2: Install the dependencies

GeoNode requires different dependencies (special the GDAL ones) so it’s required to install them by running:

sudo apt install -y build-essential gdal-bin \
libxml2 libxml2-dev gettext \
libxslt1-dev libjpeg-dev libpng-dev libpq-dev libgdal-dev \
software-properties-common build-essential \
git unzip gcc zlib1g-dev libgeos-dev libproj-dev

Step 3: clone GeoNode repository

In this tutorial, we will take into consideration GeoNode master, but you can clone the version that you prefer.

So let’s create a folder where we want to clone the repository and use the following command:

➜ mkdir /home/mattia/tutorials 
➜ cd /home/mattia/tutorials
➜ git clone https://github.com/GeoNode/geonode.git

Step 4: Install GeoNode requirements

Now we need to create a virtual environment for our project, I’m using virtualenvwrapper

➜ source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
➜ mkvirtualenv — python=/usr/bin/python3.8 medium_tutorial
(medium_tutorial) ➜

As you can see now we have a fresh new environment ready to be used to install our requirements.

NOTE: in case the virtualenvwrapper raise some issue, remember to export the WORKON_HOME=~/.virtualenvs

Now proceed to install all the dependencies required:

➜ cd geonode
➜ pip install -r requirements.txt --upgrade --no-cache-dir
➜ pip install -e . --upgrade
➜ pip install pygdal=="`gdal-config --version`.*"

Step 5: Install Postgres & PostGIS

GeoNode requires a database to run with the GIS extension. Since Spatialite is not supported, we will use Postgres (which for sure is much better for a production environment than SQLite!)

To install it, run the following command:

➜ sudo apt update -y; sudo apt install -y postgresql-13 postgresql-13-postgis-3 postgresql-13-postgis-3-scripts postgresql-13 postgresql-client-13

After the installation we need to run up the service and create the geonode user:

➜ sudo service postgresql start
➜ sudo -u postgres createuser -P geonode (use geonode as password)

Once the user is available, the next step consists of the creation of two databases named geonode and geonode_data with the PostGIS extension:

➜ sudo -u postgres createdb geonode
➜ sudo -u postgres psql -d geonode -c ‘CREATE EXTENSION postgis;’
➜ sudo -u postgres psql -d geonode -c ‘GRANT ALL ON geometry_columns TO PUBLIC;’
➜ sudo -u postgres psql -d geonode -c ‘GRANT ALL ON spatial_ref_sys TO PUBLIC;’
➜ sudo -u postgres psql -d geonode -c ‘GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO geonode;’
➜ sudo -u postgres createdb geonode_data
➜ sudo -u postgres psql -d geonode_data -c ‘CREATE EXTENSION postgis;’
➜ sudo -u postgres psql -d geonode_data -c ‘GRANT ALL ON geometry_columns TO PUBLIC;’
➜ sudo -u postgres psql -d geonode_data -c ‘GRANT ALL ON spatial_ref_sys TO PUBLIC;’
➜ sudo -u postgres psql -d geonode_data -c ‘GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO geonode;’

Once the previous steps are done, restart the Postgres service.

Step 6: Install GeoServer

GeoNode requires that GeoServer is installed and running to work.
Please refer to GeoServer doc to make it run here is the link:
GeoServer installation

Step 7: Initialize GeoNode

Ok, now we should have:

  • GeoServer up and running
  • Postgres with Postgis installed up and running

So we can proceed with the migration , we should first export the environment variables with the development configuration and then run the migration:

➜ set -a
➜ . ./.env_dev
➜ set +a
➜ python manage.py migrate

It will take few seconds to apply all the migrations, after that is needed to import some basic fixtures. The required fixtures are:
- sample_admin.json which contains the basic admin user
- default_oauth_apps.json which contains the oauth2 auth code for the admin user
- initial_data.json which contains groups, categories required

To load them is enough to use the loaddata Django command:

➜ python manage.py loaddata /home/mattia/geonode/people/fixtures/sample_admin.json
➜ python manage.py loaddata /home/mattia/geonode/base/fixtures/default_oauth_apps.json
➜ python manage.py loaddata /home/mattia/geonode/base/fixtures/initial_data.json

NOTE: be sure to change the root of the path based on your GeoNode location.

Step 8: Let it runs

If all the previous steps are successful, we can finally run GeoNode and since is a Django application is enough to use:

➜ python manage.py runserver

After some seconds, the application will be up and running at http://localhost:8000

Some Tips

I work regularly with GeoNode, so here are some tips that can help you with your daily work with GeoNode:

  • Don’t be afraid to go deeper with the official GeoNode documentation. It contains a lot of useful information about the configuration and uses cases
  • If you don’t want to invest too much time in this configuration, a docker-compose is available to make the whole set be used, but if you reading this, you are probably more interested in low-level configuration than docker!
  • I use VScode when I need to work on it, here is the launch.json file that I use to run it:
{
"name": "Python: local runserver",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"cwd": "${workspaceFolder}",
"args": [
"runserver"
],
"justMyCode": false,
"envFile": "${workspaceFolder}/.env_dev",
"django": true
}

Useful links:

GeoNode official documentation: link
GeoServer official documentation: link
GeoNode GitHub repository: link

--

--