A Django application running has GeoJSON data stored in one of the models via django-geojson. In the admin interface, this field is editable via django-leaflet. When I run the application locally with ./manage.py runserver
, the interface works just fine, the page looks like this.
However, when I deploy to Heroku, which builds just fine, and open the same Location instance in the admin interface, the blue marker isn't anywhere on the map, the map loads normally, and I get this error delivered to me:
Error creating geometry from value '{
"coordinates":[
"-105.2449000",
"40.0474000"
],
"type":"Point"
}' (Initializing geometry from JSON input requires GDAL.)
I'm just recording simple Point data in my models.py
from djgeojson.fields import PointField
from django.db import models
class Location(models.Model):
"""
A model subclass for recording geographic data.
"""
service_id = models.CharField(max_length=255, blank=True, null=True)
name = models.CharField(max_length=255, blank=True, null=True)
geom = PointField() # GeoJSON (remember, coordinates: [long, lat])
def __str__(self):
return self.name
This is my first time using geoJson, Leaflet, and Heroku. Am I missing some dependency, is there's some Heroku configuration I'm neglecting? Here's my requirements.txt
.
dj-database-url==0.4.1
Django==1.10
django-filter==0.13.0
django-geojson==2.9.0
django-leaflet==0.18.1
gunicorn==19.6.0
httplib2==0.9.2
jsonfield==1.0.3
oauth2==1.9.0.post1
oauthlib==1.1.2
psycopg2==2.6.2
PyJWT==1.4.1
python-openid==2.2.5
requests==2.10.0
requests-oauthlib==0.6.2
six==1.10.0
wheel==0.24.0
whitenoise==3.2
Heroku is currently running the heroku-18 stack and for python projects the default build pack has the geospatial libraries https://github.com/heroku/heroku-buildpack-python
To use them run heroku config:set BUILD_WITH_GEO_LIBRARIES=1
and add
GDAL_LIBRARY_PATH = os.environ.get('GDAL_LIBRARY_PATH')
GEOS_LIBRARY_PATH = os.environ.get('GEOS_LIBRARY_PATH')
to settings.py
.
See also https://github.com/heroku/heroku-buildpack-python/issues/752