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.6.tar.gz (14.8 kB view details)

Uploaded Source

Built Distributions

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

Uploaded Egg

python_sld-1.0.6-py2.6.egg (37.7 kB view details)

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for python-sld-1.0.6.tar.gz
Algorithm Hash digest
SHA256 32f842eeb01cd0a679d6c7b2cf6b34fbc76c066becbde9a84883f5193083ce72
MD5 3f713d60fe50236a0e27bde186eb9103
BLAKE2b-256 69bb0de2f305c3781051b72a6c01ef1ca1c9e84c938180a4d0cf2fae7f78777f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_sld-1.0.6-py2.7.egg
Algorithm Hash digest
SHA256 f5bce75674dd9d7d29719b7cf44c9a4ce5c49e5183cf5b30bc08c816f16ea5e7
MD5 e95761004c3ece2c854fb69126f4ff9f
BLAKE2b-256 49bd4e4e33ec1b0175bdfbb2955f0f8cbde47729fbb2294bc9dddd3d44a52abf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_sld-1.0.6-py2.6.egg
Algorithm Hash digest
SHA256 f2a48cf0fd7eddad48c7b6c4361f2175d27a73b42e2dc90f326a2fbd9927636a
MD5 7e6b784a78b5572072fc4e4d0457e1cf
BLAKE2b-256 286e68ce6095373354cd6c6f64b6409ecd33f7f98f253997881e3f8ada1b87b3

See more details on using hashes here.

Supported by

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