
Note: Use sudo apt-get install postgresql-15
This version matches with the postgis version we use in this course.
Postgresql is constantly been updated. Make sure you specify the specific version you wish to install, and check for the correct version of postgis that is compatible with your version of postgresql.
Update your system with sudo apt-get update and install the gdal libraries to enable geospatial data handling for gis applications. Then create the geospatial database for your application.
Create the spatial database for the application using PostgreSQL in admin mode, creating the CPT Water database and a waterwatch user, then enable PostGIS and PostGIS topology extensions.
Install Visual Studio Code on Linux by downloading the Debian package from code.visualstudio.com and installing it. Verify that Visual Studio Code has been installed.
Install django-leaflet, django-geojson, and geojson, then update settings.py by adding the Django GIS and Waterwatch apps. Configure a PostGIS connection to localhost and run manage.py migrate to establish PostgreSQL access.
Create the model class for a geospatial Django app in models.py, defining id, suburb, and a point geometry, then run migrations to form the PostgreSQL table.
Download the waterwatch dataset from GitHub, install openpyxl and pandas to read the Excel file, and analyze monthly suburb water consumption in kilolitres to identify high-use areas for alerts.
Develop a Django admin workflow that reads an Excel dataset into a pandas dataframe, converts coordinates to a point, and stores them in a spatial table with Leaflet geo admin.
Add the Django Geojson serializer and leaflet configuration in settings.py, set a default map with three base maps (OpenStreetMap, terrain, data) and Esri/CartoDB tiles with attributions.
Create a templates folder in the waterwatch app, add an app subfolder, and build layout.html as the base html with a shared default style for all pages.
Build a responsive layout.html for a Django Leaflet map app, wiring HTML5 structure, head and body, static assets, and a modular sidebar with Leaflet, GeoJSON, and charts integration.
Create geojson datasets from a water consumption model and expose two endpoints for a map app: water consumption data and top ten consumers.
Create a legend for a map by adding a bottom-right Leaflet control that displays three circle marker sizes representing 0–4 kilolitres, 5–10 kilolitres, and 11–20 kilolitres.
Create a bar chart legend on a Leaflet map, using Chart.js to display a horizontal bar chart of the top ten water consumers, with a styled info control and canvas.
Create a horizontal bar chart with Chart.js showing the top ten water consumers in kiloliters, by fetching and parsing JSON data via Ajax and extracting suburb labels and kiloliter values.
Welcome to the Creating Smart Maps with Python and Leaflet Linux Version course. We'll be building a python GIS application from scratch using a variety of open source technologies. The purpose of this course and many more to follow, is to learn to create geospatial analytics and convert it into a functional application.
In our use case we will be working with residential water consumption data and we will be applying data processing techniques to extract transform and load the data into our spatial database. Once we have processed and cleaned the data, we will use it as a data source for building our GeoDjango Web Map Application.
We will be powering our application with a PostgreSQL and PostGIS database. In the Front-End we'll use Bootstrap, JavaScript, Leaflet and Ajax. On the server side we'll be using Python and Django combined with use of scientific libraries like pandas, for our data transformation and conversion operations. The operating system that we will be working on is Ubuntu Linux LTS.
Some skills that you can expect to derive after completing the course are the following:
You will learn how to build a Spatial Database using Postgresql and PostGIS.
You will learn how to create charts with Chart.js.
You will learn to build Web Maps with Leaflet.js.
You will learn how to build REST API Endpoints.
You will learn some JavaScript programming.
You will learn how to build Web Applications using the Django MVC framework.