Login

Snippets by jbronn

Snippet List

Map GPX files to 3D GeoDjango Models

`GPXMapping` is a subclass of `LayerMapping` that imports GPX files into 3D GeoDjango models (requires Django 1.2 or SVN r11742 and higher). Here's an example of GeoDjango models for GPX points and tracks, respectively: from django.contrib.gis.db import models class GPXPoint(models.Model): timestamp = models.DateTimeField() point = models.PointField(dim=3) objects = models.GeoManager() def __unicode__(self): return unicode(self.timestamp) class GPXTrack(models.Model): track = models.MultiLineStringField(dim=3) objects = models.GeoManager() Assuming the above models, then `GPXMapping` may be used to load GPX tracks and waypoints (including elevation Z values): track_point_mapping = {'timestamp' : 'time', 'point' : 'POINT', } track_mapping = {'track' : 'MULTILINESTRING'} gpx_file = '/path/to/file.gpx' lm = GPXMapping(GPXPoint, gpx_file, track_point_mapping, layer='track_points') lm.save(verbose=True) lm = GPXMapping(GPXTrack, gpx_file, track_mapping, layer='tracks') lm.save(verbose=True)

  • gis
  • geodjango
  • 3d
  • gpx
  • layermapping
Read More

google.js template for GoogleAdmin

JavaScript template for [GoogleAdmin](http://www.djangosnippets.org/snippets/1144/). Also requires the [google.html](http://www.djangosnippets.org/snippets/1145/) template. Install in `gis/admin` somewhere in your template path.

  • gis
  • google
  • map
  • gmaps
  • layer
  • openlayers
Read More

google.html template for GoogleAdmin

HTML template for [GoogleAdmin](http://www.djangosnippets.org/snippets/1144/). Also requires the [google.js](http://www.djangosnippets.org/snippets/1146/) template. Install in `gis/admin` somewhere in your template path.

  • gis
  • google
  • map
  • gmaps
  • layer
  • openlayers
Read More

GoogleAdmin: GMaps base layer in Geographic Admin (GeoDjango)

This GeoDjango subclass substitutes in the Google Maps base layer instead of the default one provided by Open Street Map. Requires the [google.html](http://www.djangosnippets.org/snippets/1145/) and [google.js](http://www.djangosnippets.org/snippets/1146/) templates (must be placed in `gis/admin` somewhere in your template path). Requires a Google Maps API key -- please abide by Google's [terms of service](http://code.google.com/apis/maps/terms.html).

  • gis
  • google
  • map
  • gmaps
  • layer
  • openlayers
Read More

chdjango

This is a convenient script for those working with different branches of Django. Place all of your branches in `~/django` (e.g., `~/django/newforms-admin`, `~/django/trunk`) and you're ready to quickly change between them. For example: `chdjango.py trunk`.

  • django
  • path
  • change
  • chdjango
  • branches
  • pth
  • site-packages
Read More

MaxMind(R) GeoIP Lite CSV Import

Use this script to import the Maxmind GeoIP lite CSV datasets into your database. This takes at least 200MB of RAM; the resulting database will be ~400MB. Stick in the same directory as the [models](http://www.djangosnippets.org/snippets/327/). Make sure to set `DEBUG=False` to prevent running out of memory during import.

  • log
  • csv
  • gis
  • ip
  • geolocation
  • maxmind
  • geodjango
  • import
Read More

MaxMind(R) GeoIP Lite geolocation models

This provides GeoDjango models for the maxmind GeoIP Lite data products. Use the corresponding [CSV import script](http://www.djangosnippets.org/snippets/328/) for data import. Requires: [GeoDjango](http://code.djangoproject.com/wiki/GeoDjango) and the [BigIntegerField patch](http://code.djangoproject.com/attachment/ticket/399/django-bigint-20070712.patch) by Peter Nixon.

  • log
  • gis
  • ip
  • geolocation
  • maxmind
  • geodjango
Read More

jbronn has posted 7 snippets.