Package djsld :: Module generator
[hide private]
[frames] | no frames]

Module generator

source code

Generate StyledLayerDescriptor objecs for django querysets.

This generator uses the python-sld and pysal libraries to generate classes for map classification, and returns a StyledLayerDescriptor class object. This class object may be serialized to an SLD XML file, which is useful for many GIS and mapping software packages.

License

Copyright 2011-2012 David Zwarg <dzwarg@azavea.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Author: David Zwarg

Contact: dzwarg@azavea.com

Copyright: 2011-2012, Azavea

License: Apache 2.0

Version: 1.0.7

Functions [hide private]
sld.StyledLayerDescriptor
as_equal_interval(*args, **kwargs)
Generate equal interval classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_fisher_jenks(*args, **kwargs)
Generate Fisher-Jenks classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_jenks_caspall(*args, **kwargs)
Generate Jenks-Caspall classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_jenks_caspall_forced(*args, **kwargs)
Generate Jenks-Caspall Forced classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_jenks_caspall_sampled(*args, **kwargs)
Generate Jenks-Caspall Sampled classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_max_p_classifier(*args, **kwargs)
Generate Max P classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_maximum_breaks(*args, **kwargs)
Generate Maximum Breaks classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_natural_breaks(*args, **kwargs)
Generate Natural Breaks classes from the provided queryset.
source code
sld.StyledLayerDescriptor
as_quantiles(*args, **kwargs)
Generate Quantile classes from the provided queryset.
source code
sld.StyledLayerDescriptor
_as_classification(classification, queryset, field, nclasses, geofield='geom', propertyname=None, userstyletitle=None, featuretypestylename=None, colorbrewername='', invertgradient=False, **kwargs)
Accept a queryset of objects, and return the values of the class breaks on the data distribution.
source code

Imports: Symbolizer, Mark, parse, FeatureTypeStyle, CssParameter, copy, Rules, StyledLayerDescriptor, StyleItem, NamedLayer, logger, Graphic, CssParameters, TextSymbolizer, urllib2, Rule, Element, Filter, tostring, PropertyCriterion, XMLSchema, PolygonSymbolizer, UserStyle, logging, PointSymbolizer, NamedTemporaryFile, XMLSyntaxError, Stroke, SLDNode, LineSymbolizer, Font, os, Fill, array, ndarray, Jenks_Caspall, Map_Classifier, Std_Mean, Percentiles, Natural_Breaks, Fisher_Jenks, Maximum_Breaks, quantile, Quantiles, Jenks_Caspall_Forced, Max_P_Classifier, K_classifiers, Box_Plot, Jenks_Caspall_Sampled, Equal_Interval, gadf, User_Defined, fields


Function Details [hide private]

as_equal_interval(*args, **kwargs)

source code 

Generate equal interval classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Equal Interval classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Equal_Interval

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_fisher_jenks(*args, **kwargs)

source code 

Generate Fisher-Jenks classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Fisher Jenks classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Fisher_Jenks

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_jenks_caspall(*args, **kwargs)

source code 

Generate Jenks-Caspall classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Jenks Caspall classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Jenks_Caspall

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_jenks_caspall_forced(*args, **kwargs)

source code 

Generate Jenks-Caspall Forced classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Jenks Caspall Forced classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Jenks_Caspall_Forced

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_jenks_caspall_sampled(*args, **kwargs)

source code 

Generate Jenks-Caspall Sampled classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Jenks Caspall Sampled classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Jenks_Caspall_Sampled

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_max_p_classifier(*args, **kwargs)

source code 

Generate Max P classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Max P classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Max_P_Classifier

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_maximum_breaks(*args, **kwargs)

source code 

Generate Maximum Breaks classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Maximum Breaks classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Maximum_Breaks

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_natural_breaks(*args, **kwargs)

source code 

Generate Natural Breaks classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Natural Breaks classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Natural_Breaks

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

as_quantiles(*args, **kwargs)

source code 

Generate Quantile classes from the provided queryset. If the queryset is empty, no class breaks are returned. For more information on the Quantile classifier, please visit:

http://pysal.geodacenter.org/1.2/library/esda/mapclassify.html#pysal.esda.mapclassify.Quantiles

Parameters:
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geometry field. Defaults to 'geom'.
Returns: sld.StyledLayerDescriptor
An SLD object that represents the class breaks.

_as_classification(classification, queryset, field, nclasses, geofield='geom', propertyname=None, userstyletitle=None, featuretypestylename=None, colorbrewername='', invertgradient=False, **kwargs)

source code 

Accept a queryset of objects, and return the values of the class breaks on the data distribution. If the queryset is empty, no class breaks are computed.

Parameters:
  • classification (pysal classifier) - A classification class defined in pysal.esda.mapclassify. As of version 1.0.1, this list is comprised of:
    • Equal_Interval
    • Fisher_Jenks
    • Jenks_Caspall
    • Jenks_Caspall_Forced
    • Jenks_Caspall_Sampled
    • Max_P_Classifier
    • Maximum_Breaks
    • Natural_Breaks
    • Quantiles
  • queryset (QuerySet) - The query set that contains the entire distribution of data values.
  • field (string) - The name of the field on the model in the queryset that contains the data values.
  • nclasses (integer) - The number of class breaks desired.
  • geofield (string) - The name of the geography column on the model. Defaults to 'geom'
  • propertyname (string) - The name of the filter property name, if different from the model field.
  • userstyletitle (string) - The title of the UserStyle element.
  • featuretypestylename (string) - The name of the FeatureTypeStyle element.
  • colorbrewername (string) - The name of a colorbrewer ramp name. Must have the same # of corresponding classes as nclasses.
  • invertgradient (boolean) - Should the resulting SLD have colors from high to low, instead of low to high?
  • kwargs (keywords) - Additional keyword arguments for the classifier.
Returns: sld.StyledLayerDescriptor
An SLD class object that represents the classification scheme and filters.