gis.db.models.functions.AsGeoJSON

class AsGeoJSON(expression, bbox=False, crs=False, precision=8, **extra)

Availability: PostGIS, SpatiaLite

Accepts a single geographic field or expression and returns a GeoJSON representation of the geometry. Note that the result is not a complete GeoJSON structure but only the geometry key content of a GeoJSON structure. See also GeoJSON Serializer.

Example:

>>> City.objects.annotate(json=AsGeoJSON('point')).get(name='Chicago').json
{"type":"Point","coordinates":[-87.65018,41.85039]}
Keyword Argument Description
bbox Set this to True if you want the bounding box to be included in the returned GeoJSON.
crs Set this to True if you want the coordinate reference system to be included in the returned GeoJSON.
precision It may be used to specify the number of significant digits for the coordinates in the GeoJSON representation – the default value is 8.
doc_Django
2016-10-09 18:37:21
Comments
Leave a Comment

Please login to continue.