Serve vectorial map layers with Django
Project description
django-geojson
INSTALL
pip install django-geojson
USAGE
GeoJSON layer view
Very useful for web mapping :
from djgeojson.views import GeoJSONLayerView
class MeetingLayer(GeoJSONLayerView):
model = Meeting
fields = ('title', 'datetime',)
# Options
srid = 4326 # projection
precision = 4 # float
simplify = 0.5 # generalization
Consume the vector layer as usual, for example, with Leaflet :
var layer = L.GeoJSON();
map.addLayer(layer);
$.getJSON('{% url viewname %}', function (data){
layer.addData(data);
});
GeoJSON template filter
Will work either for a model, a geometry field or a queryset.
{% load geojson_tags %}
var feature = {{ object|geojsonfeature }};
var geom = {{ object.geom|geojsonfeature }};
var collection = {{ object_list|geojsonfeature }};
Dump GIS models
Register the serializer in your project :
# settings.py
SERIALIZATION_MODULES = {
'geojson' : 'djgeojson.serializers'
}
Command-line dumpdata can export files, viewable in GIS software like QGis :
django dumpdata --format=geojson yourapp.Model > export.geojson
Works with loaddata as well, which can now import GeoJSON files.
LICENSE
Lesser GNU Public License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-geojson-1.0.0.zip
(14.0 kB
view details)
File details
Details for the file django-geojson-1.0.0.zip.
File metadata
- Download URL: django-geojson-1.0.0.zip
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee399b45a1f58dc1625bb2b3f4562ddf7d0fc547ed4faee25a04b9fd00536e28
|
|
| MD5 |
b564bbded27cf32d7ed64bc96b026031
|
|
| BLAKE2b-256 |
d7aea2e8dce46150e06afe83656f3b8bb5b6e52e494c6b8580d5b73c28688a6a
|