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.7.tar.gz (15.1 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.7-py2.7.egg (37.7 kB view details)

Uploaded Egg

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

Uploaded Egg

File details

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

File metadata

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

File hashes

Hashes for python-sld-1.0.7.tar.gz
Algorithm Hash digest
SHA256 06ae65b4e3e2f73093b111fea3b842065e36a3fc87094efaae22ec47aca3f276
MD5 e7ed29de196dc3cf212fd776231db626
BLAKE2b-256 4bc33f22e63c751c33cc99d75ec5af2a18f26044f52250dd9850484399a697b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_sld-1.0.7-py2.7.egg
Algorithm Hash digest
SHA256 1329a15b3d51201deca67e9fa9f5d010b8aea14fa10ab26dd064481f5475a690
MD5 95de7f5758d8f7e4b38dd84e5be86205
BLAKE2b-256 81b313ca754fac3f7f3bd4d36297e397ad9941053076f1927ca054d14493310b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_sld-1.0.7-py2.6.egg
Algorithm Hash digest
SHA256 5aaaab9dadeb83886c78142d3a86709e1d51f8e03631a8330889de297d33a71a
MD5 120f1813008332c431d910372a6abfec
BLAKE2b-256 bed42b42216511c9d9c46cfc4781f9cf72a416bb1c1fe3724ed16bd6ed636a90

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