Map GPX files to 3D GeoDjango Models

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
import os
from django.contrib.gis.utils import LayerMapping

class GPXMapping(LayerMapping):
    def __init__(self, *args, **kwargs):
        # Setting this environment variable tells OGR to use the elevation
        # attribute as the Z coordinate value on the geometries.  See:
        #  http://www.gdal.org/ogr/drv_gpx.html
        os.environ['GPX_ELE_AS_25D'] = 'YES'
        super(GPXMapping, self).__init__(*args, **kwargs)
        # Unset the environment variable, so it doesn't affect other
        # GPX DataSource objects.
        os.environ.pop('GPX_ELE_AS_25D')

More like this

  1. Google v3 geocoding for Geodjango admin site by samhag 6 months, 3 weeks ago
  2. GeoDjango maps in admin TabularInlines by alanB 2 years, 7 months ago
  3. GoogleAdmin: GMaps base layer in Geographic Admin (GeoDjango) by jbronn 4 years, 7 months ago
  4. GeoJSON Serializer for GeoDjango (gis) by danielsokolowski 2 years ago
  5. Updated: GeoJSON Serializer for GeoDjango (gis) by danielsokolowski 1 year, 6 months ago

Comments

wilane (on December 12, 2009):

Great, thanks for this great recipe. Is there any way to plot it on a GoogleMap widget which seems to only accept LineStrings, or I'm overlooking something ?

Keep up the good work.

#

(Forgotten your password?)