Login

Tag "GeoJson"

Snippet List

Updated: GeoJSON Serializer for GeoDjango (gis)

Unfortunately the built in Django JSON serialzer encodes GeoDjango GeometyrField as WKT text. This snippet extends django's serializer and adds support for GEOJson format. Built in JSON serializer output: [{"pk": 1, ... "geopoint": "POINT (-76.5060419999999937 44.2337040000000030)" ... }] GeoJSON serializer ouput: [{"pk": 1, ... "geopoint": {"type": "Point", "coordinates": [-76.503296000000006, 44.230956999999997], "__GEOSGeometry__": [ "__init__", [ "SRID=4326;POINT (-75.5129950000000036 44.2442360000000008)" ] ] }] Note: the "__GEOSGeometry__" is a class hint as defined by JSON-RCP and used during deserilization.

  • GeoJson
  • Serializer
  • Deserializer
Read More

GeoJSON Serializer for GeoDjango (gis)

**Please use the updated version http://djangosnippets.org/snippets/2596/** Unfortunately the built in Django JSON serialzer encodes GeoDjango GeometyrField as simple text. This snippet extends django's serializer and adds support for GeoJson format. Built in JSON serializer output: [{"pk": 1, ... "geopoint": "POINT (-76.5060419999999937 44.2337040000000030)" ... }] GeoJSON serializer ouput: [{"pk": 1, ... "geopoint": {"type": "Point", "coordinates": [-76.503296000000006, 44.230956999999997]}}]

  • GeoJson
  • Serializer
Read More

2 snippets posted so far.