At Gramercy Studios, we’ve been using PostGIS (the GIS extension to PostgreSQL) to store locations as spatial fields in the database. This allows for intelligent database querying – e.g. to find points within 1km of a selected latitude/longitude, determine what city/country (POLYGON) points are contained within, to find the bounding box surrounding a number of geometry features, or simply find the distance between two points.
GeoDjango adds support for PostGIS (django.contrib.gis.db.backends.postgis) and GIS fields (PointField, PolygonField, etc) to Django, which lets us build location-enabled web APIs from a high level. Some configuration is required to get all this running smoothly locally (OSX), on Heroku and with Circle CI, a continuous integration/deployment service we’re using.
We’ve found that the Heroku multi buildpack (BUILDPACK_URL: https://github.com/ddollar/heroku-buildpack-multi.git) with the following buildpacks (Python and GEO) works well:
With Postgres.app (and Django/geos/etc) installed locally on our macs, the following settings file allows us to have full GIS support when developing our Django apps locally, and when deployed to Heroku. (You’ll need to run psql and create the postgis extension locally – see the top of the settings file)
On Circle CI, we found that the postgis extension wasn’t getting created, so we added a command to run on post-database creation in our circle.yml configuration file:
Hopefully this will help someone out in the future – enjoy!