Django speaking WFS 2.0 (exposing GeoDjango model fields)
Project description
django-gisserver
Django speaking WFS 2.0 to expose geo data.
Features
- WFS 2.0 Basic implementation.
- GML 3.2 output.
- Standard and spatial filtering (FES 2.0)
- GeoJSON and CSV export formats.
- Extensible view/operations.
- Uses GeoDjango queries for filtering.
- Streaming responses for large datasets.
Documentation
For more details, see: https://django-gisserver.readthedocs.io/
Test drive
- Run
docker compose up. - Open http://localhost:8000/ to see this works.
- Connect to http://localhost:8000/wfs/ in your GIS client (e.g. QGis) and zoom to Amsterdam.
- Add more data on the map using the Django admin, username and password are both "admin".
Quickstart
Install the module in your project:
pip install django-gisserver
Add it to the INSTALLED_APPS:
INSTALLED_APPS = [
...
"gisserver",
]
Create a model that exposes a GeoDjango field:
from django.contrib.gis.db.models import PointField
from django.db import models
class Restaurant(models.Model):
name = models.CharField(max_length=200)
location = PointField(null=True)
def __str__(self):
return self.name
Write a view that exposes this model as a WFS feature:
from gisserver.crs import CRS, CRS84, WEB_MERCATOR
from gisserver.features import FeatureType, ServiceDescription
from gisserver.views import WFSView
from .models import Restaurant
# As example, the local coordinate system for The Netherlands
RD_NEW = CRS.from_string("urn:ogc:def:crs:EPSG::28992")
class PlacesWFSView(WFSView):
"""An simple view that uses the WFSView against our test model."""
xml_namespace = "http://example.org/gisserver"
# The service metadata
service_description = ServiceDescription(
title="Places",
abstract="Unittesting",
keywords=["django-gisserver"],
provider_name="Django",
provider_site="https://www.example.com/",
contact_person="django-gisserver",
)
# Each Django model is listed here as a feature.
feature_types = [
FeatureType(
Restaurant.objects.all(),
fields="__all__",
other_crs=[RD_NEW, CRS84, WEB_MERCATOR]
),
]
Use that view in the URLConf:
from django.urls import path
from . import views
urlpatterns = [
path("/wfs/places/", views.PlacesWFSView.as_view()),
]
You can now use http://localhost:8000/wfs/places/ in your GIS application. It will perform requests such as:
- http://localhost:8000/wfs/places/?SERVICE=WFS&REQUEST=GetCapabilities&ACCEPTVERSIONS=2.0.0,1.1.0,1.0.0
- http://localhost:8000/wfs/places/?SERVICE=WFS&REQUEST=DescribeFeatureType&VERSION=2.0.0&TYPENAMES=restaurant
- http://localhost:8000/wfs/places/?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=restaurant&STARTINDEX=0&COUNT=1000&SRSNAME=urn:ogc:def:crs:EPSG::28992
By adding &OUTPUTFORMAT=geojson or &OUTPUTFORMAT=csv to the GetFeature request, the GeoJSON and CSV outputs are returned.
The CSV output has an unlimited page size, as it's quite performant.
Why this code is shared
The "datapunt" team of the Municipality of Amsterdam develops software for the municipality. Much of this software is then published as Open Source so that other municipalities, organizations and citizens can use the software as a basis and inspiration to develop similar software themselves. The Municipality of Amsterdam considers it important that software developed with public money is also publicly available.
This package is initially developed by the City of Amsterdam, but the tools and concepts created in this project can be used in any city.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_gisserver-2.2.1.tar.gz.
File metadata
- Download URL: django_gisserver-2.2.1.tar.gz
- Upload date:
- Size: 185.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83bda613ea26a401a9ab9fb306e58bb631e9d61fe5a31521e1c15866e928c505
|
|
| MD5 |
62449a47c769aea36543577727e2ee03
|
|
| BLAKE2b-256 |
eaf4215be7d14b2f599e0ae7dd6e4a0fddcac7652a8f9bbb948d3e7ea1631c60
|
File details
Details for the file django_gisserver-2.2.1-py3-none-any.whl.
File metadata
- Download URL: django_gisserver-2.2.1-py3-none-any.whl
- Upload date:
- Size: 205.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eab4cd641cc3ea27b779650d5837397c0ca3f5e1e46844428769af794123b3b7
|
|
| MD5 |
03afea6c7e970045ca200f4bb5bad884
|
|
| BLAKE2b-256 |
4b2739ac3f0e1bd25b7d9aa55baacbfd3ca14e5052bcda3b71891730fdc13c66
|