Skip to main content

A simple python library that enables dynamic SLD creation and manipulation.

Project description

python-sld

A python library for reading, writing, and manipulating SLD files.

Requirements

The lxml library is required for XML parsing and XML Schema validation. This requirement is listed in requirements.txt, and may be installed using pip with this command:

> sudo pip install -r requirements.txt

Installation

> easy_install python-sld

OR

> pip install python-sld

Usage

Using python-sld to create SLD documents is as easy as instantiating a StyledLayerDescriptor class object.

import sld mysld = StyledLayerDescriptor()

You may also read an existing SLD document in by passing it as a parameter:

import sld mysld = StyledLayerDescriptor(‘mysld.sld’)

Addition of most elements are performed on the parent element, since they are related to parent nodes in order to preserve compliance:

nl = mysld.create_namedlayer() ustyle = nl.create_style()

A couple class objects represent collections of nodes, such as Rules and CssParameters. They are properties of their parent classes (FeatureTypeStyle and Fill/Stroke/Font respectively). They behave as python lists, and you can access any of their items using a python list pattern:

rule1 = fts.Rules[0] print len(fts.Rules) fts.Rules[0] = rule1

Filter objects are pythonic, and when combined with the ‘+’ operator, they become ogc:And filters. When combined with the ‘|’ operator, they become ogc:Or filters.

filter_1 = Filter(rule) # set filter 1 properties

filter_2 = Filter(rule) # set filter 2 properties

rule.Filter = filter_1 + filter_2

You may also construct a filter from an expression when using the create_filter method on the Rule object:

filter = rule.create_filter(‘population’, ‘>’, ‘100’)

Implementation

At the current time, python-sld does ‘’not’’ support the full SLD specification. The current implementation supports the following SLD elements:

  • StyledLayerDescriptor

  • NamedLayer

  • Name (of NamedLayer)

  • UserStyle

  • Title (of UserStyle and Rule)

  • Abstract

  • FeatureTypeStyle

  • Rule

  • ogc:Filter

  • ogc:And

  • ogc:Or

  • ogc:PropertyIsNotEqualTo

  • ogc:PropertyIsLessThan

  • ogc:PropertyIsLessThanOrEqualTo

  • ogc:PropertyIsEqualTo

  • ogc:PropertyIsGreaterThanOrEqualTo

  • ogc:PropertyIsGreaterThan

  • ogc:PropertyIsLike

  • ogc:PropertyName

  • ogc:Literal

  • PointSymbolizer

  • LineSymbolizer

  • PolygonSymbolizer

  • TextSymbolizer

  • Mark

  • Graphic

  • Fill

  • Stroke

  • Font

  • CssParameter

Support

If you have any problems or questions, please visit the python-sld project on github: https://github.com/azavea/python-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

python-sld-1.0.8.tar.gz (16.9 kB view details)

Uploaded Source

Built Distributions

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

python_sld-1.0.8-py2.7.egg (37.7 kB view details)

Uploaded Egg

python_sld-1.0.8-py2.6.egg (37.8 kB view details)

Uploaded Egg

File details

Details for the file python-sld-1.0.8.tar.gz.

File metadata

  • Download URL: python-sld-1.0.8.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python-sld-1.0.8.tar.gz
Algorithm Hash digest
SHA256 5d9a35929f2655895e1e608868eddcc82febc9c5c54bf7fa0c9531fa5b91523a
MD5 cba9a740efe1fc32accfdafe57d19a7c
BLAKE2b-256 4783e575cda60a32f4def463773a5dd9ea929a0bc3ff279960cce7e86468d2e6

See more details on using hashes here.

File details

Details for the file python_sld-1.0.8-py2.7.egg.

File metadata

  • Download URL: python_sld-1.0.8-py2.7.egg
  • Upload date:
  • Size: 37.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python_sld-1.0.8-py2.7.egg
Algorithm Hash digest
SHA256 13bf5ac02b25a57f95e0d8dbe87d45e4a6402b4c6253368ec544c12d8b7ff07e
MD5 c9209dcc20ec3a55a68bd4c737550437
BLAKE2b-256 f3dc11d8afd794a5d1acd2b681c4b0ad62f6b1cba9c54e5b5d09a4ac70e59755

See more details on using hashes here.

File details

Details for the file python_sld-1.0.8-py2.6.egg.

File metadata

  • Download URL: python_sld-1.0.8-py2.6.egg
  • Upload date:
  • Size: 37.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for python_sld-1.0.8-py2.6.egg
Algorithm Hash digest
SHA256 133fbaf37a634ad78d1419fc9dad8607872b79560f96aaae739c01740a670759
MD5 052ce353e69c69a518f8feec7e09255a
BLAKE2b-256 ea159bb86072d398f3522dc9262ec47d96eb5eed0d26bb3536e41023fe2b9acb

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