The Django framework integrates extensions to handle geospatial data. To setup an application which is using such extensions, a bit of work is required:
- PostgreSQL with PostGIS extension
- Geospatial libraries
Enable PostgreSQL PostGIS Extension
Scalingo PostgreSQL includes several extensions. PostGIS is an extension to handle geospatial data. After adding a PostgreSQL database to your application, you can enable the PostGIS extension with:
$ scalingo --app my-app pgsql-console > CREATE EXTENSION postgis;
Next step is to install the libraries Django requires to manipulate these data.
Install Geospatial Libraries
These libraries are proj, geos and gdal. Considering that they are not used commonly, they are not included in our default environment so you need to install them at deployment time.
Usage of the geo-buildpack
To deploy an application with these libraries you need to use an additional buildpack along with the default Python buildpack.
.buildpacks file at the root of your project with the following
Then setup the multi buildpack for your project to handle this file:
scalingo env-set BUILDPACK_URL=https://github.com/Scalingo/multi-buildpack
Deploy your application
git add .buildpacks git commit -m "Use geo-buildpack as long as python-buildpack" git push scalingo master
Then you’ll see in your deployment output:
=====> Downloading Buildpack: https://github.com/Scalingo/geo-buildpack.git =====> Detected Framework: geos/gdal/proj Using geos version: 3.4.2 Using gdal version: 1.11.1 Using proj version: 4.8.0_1 ...