Skip to main content

A simple django library that generates SLD documents from geographic models.

Project description

django-sld

A django library that generates SLD documents from geographic models.

Requirements

  • django Required for models and spatial fields.

  • python-sld Required for reading and generating SLD XML files.

  • pysal Required for classification algorithms.

  • colorbrewer Required for color lookup definitions.

To install these requirements, you may use pip to install these packages (except for django) with this command:

> sudo pip install -r requirements.txt

Installation

> easy_install django-sld

OR

> pip install django-sld

Usage

This library implements a single module named “generator” that contains all the methods of interacting with the classification algorithms. Assuming that you have a geographic model in geodjango, you may classify your distribution with by constructing a queryset, and feeding it to the generator.

Assuming you have a spatial model named MySpatialModel, with a data field of population, you can classify all your data into 10 quantile classes with:

from djsld import generator

qs = MySpatialModel.objects.all() sld = generator.as_quantiles(qs, ‘population’, 10)

You may also any queryset to generate classes, such as a filtered queryset:

qs = MySpatialModel.objects.filter(owner__name = ‘David’) sld = generator.as_quantiles(qs, ‘population’, 10)

If your spatial model has a different geometry column name other than ‘geom’, you may specify that field as the geofield keyword:

sld = generator.as_quantiles(qs, ‘population’, 10, geofield=’state’)

The data field may also be distantly related to the queryset in question. For this example, assume that MySpatialModel has a foreign key to a model named Route, and that the data value you would like to classify is a field of the Route model:

sld = generater.as_quantiles(qs, ‘route__traffic’, 10)

By default, all the generator methods use a plain black-to-white color ramp. The number of classes must match an available color scheme, or the color ramp will default to black-to-white. You may specify a colorbrewer ramp name with the colorbrewername keyword:

sld = generator.as_quantiles(qs, ‘population’, 9, colorbrewername=’Greys’)

You may also reverse the order of the ramp, by specifying the invertgradient keyword:

sld = generator.as_quantiles(qs, ‘population’, 9, colorbrewername=’Reds’,

invertgradient=True)

Support

If you have any problems, questions, or comments, please visit the django-sld project on github: https://github.com/azavea/django-sld/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sld-1.0.7.tar.gz (11.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

django_sld-1.0.7-py3.2.egg (19.2 kB view details)

Uploaded Egg

django_sld-1.0.7-py2.7.egg (23.8 kB view details)

Uploaded Egg

File details

Details for the file django-sld-1.0.7.tar.gz.

File metadata

  • Download URL: django-sld-1.0.7.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-sld-1.0.7.tar.gz
Algorithm Hash digest
SHA256 69576b3f3633146d413dabda9a74b64bd2042ef6f4d99702d48328318b7743f1
MD5 5db76ec68911fb730c465b16aeb0f278
BLAKE2b-256 b93d9e2f01cc9a272d37709c98174560defbf83cc77553e13be4212a10976fe0

See more details on using hashes here.

File details

Details for the file django_sld-1.0.7-py3.2.egg.

File metadata

  • Download URL: django_sld-1.0.7-py3.2.egg
  • Upload date:
  • Size: 19.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django_sld-1.0.7-py3.2.egg
Algorithm Hash digest
SHA256 00db27ee844b97e781bff52bd6415a303ec6513b19c6e56d5ce243c1d1a3beeb
MD5 2dfc240f511af064387d2355a8233f00
BLAKE2b-256 82bb7934d2e40811bd809d36f161371d42edade0660a2acbe2b5d17d139c40a0

See more details on using hashes here.

File details

Details for the file django_sld-1.0.7-py2.7.egg.

File metadata

  • Download URL: django_sld-1.0.7-py2.7.egg
  • Upload date:
  • Size: 23.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django_sld-1.0.7-py2.7.egg
Algorithm Hash digest
SHA256 f631bcff823e0c22acf674fc6413119d11b24d676393c8ab971003caf5288e6f
MD5 834ae6c21b99e14782ba442d791a493e
BLAKE2b-256 6e5f9ceaa4a3c585a3e7a8b786abd6e61a4447c7052a9fc54cc062d7f7325fd8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page