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')