Package mapnik :: Module _mapnik :: Class Layer

Class Layer

 object --+    
          |    
??.instance --+
              |
             Layer

A Mapnik map layer.

Instance Methods
 
__getinitargs__(...)
__getinitargs__( (Layer)arg1) -> tuple :
 
__getstate__(...)
__getstate__( (Layer)arg1) -> tuple :
 
__init__(...)
__init__( (object)arg1, (str)arg2 [, (str)arg3]) -> None : Create a Layer with a named string and, optionally, an srs string.
 
__reduce__(...)
helper for pickle
 
__setstate__(...)
__setstate__( (Layer)arg1, (tuple)arg2) -> None :
 
envelope(...)
envelope( (Layer)arg1) -> Box2d : Return the geographic envelope/bounding box.
 
visible(...)
visible( (Layer)arg1, (float)arg2) -> bool : Return True if this layer's data is active and visible at a given scale.

Inherited from unreachable.instance: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  __instance_size__ = 152
  __safe_for_unpickling__ = True
Properties
  active
Get/Set whether this layer is active and will be rendered (same as status property).
  buffer_size
Get/Set the size of buffer around layer in pixels.
  cache_features
Get/Set whether features should be cached during rendering if used between multiple styles
  clear_label_cache
Get/Set whether to clear the label collision detector cache for this layer during rendering
  datasource
The datasource attached to this layer.
  group_by
Get/Set the optional layer group name.
  maximum_extent
The maximum extent of the map.
  maxzoom
Get/Set the maximum zoom lever of the layer.
  minzoom
Get/Set the minimum zoom lever of the layer.
  name
Get/Set the name of the layer.
  queryable
Get/Set whether this layer is queryable.
  srs
Get/Set the SRS of the layer.
  status
Get/Set whether this layer is active and will be rendered.
  styles
The styles list attached to this layer.

Inherited from object: __class__

Method Details

__getinitargs__(...)

 

__getinitargs__( (Layer)arg1) -> tuple :

    C++ signature :
        boost::python::tuple __getinitargs__(mapnik::layer)

__getstate__(...)

 

__getstate__( (Layer)arg1) -> tuple :

    C++ signature :
        boost::python::tuple __getstate__(mapnik::layer)

__init__(...)
(Constructor)

 

__init__( (object)arg1, (str)arg2 [, (str)arg3]) -> None :
    Create a Layer with a named string and, optionally, an srs string.
    
    The srs can be either a Proj.4 epsg code ('+init=epsg:<code>') or
    of a Proj.4 literal ('+proj=<literal>').
    If no srs is specified it will default to '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
    
    Usage:
    >>> from mapnik import Layer
    >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
    >>> lyr
    <mapnik._mapnik.Layer object at 0x6a270>
    

    C++ signature :
        void __init__(_object*,std::string [,std::string])

Overrides: object.__init__

__reduce__(...)

 

helper for pickle

Overrides: object.__reduce__
(inherited documentation)

__setstate__(...)

 

__setstate__( (Layer)arg1, (tuple)arg2) -> None :

    C++ signature :
        void __setstate__(mapnik::layer {lvalue},boost::python::tuple)

envelope(...)

 

envelope( (Layer)arg1) -> Box2d :
    Return the geographic envelope/bounding box.
    Determined based on the layer datasource.
    
    Usage:
    >>> from mapnik import Layer
    >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
    >>> lyr.envelope()
    box2d(-1.0,-1.0,0.0,0.0) # default until a datasource is loaded
    

    C++ signature :
        mapnik::box2d<double> envelope(mapnik::layer {lvalue})

visible(...)

 

visible( (Layer)arg1, (float)arg2) -> bool :
    Return True if this layer's data is active and visible at a given scale.
    
    Otherwise returns False.
    Accepts a scale value as an integer or float input.
    Will return False if:
        scale >= minzoom - 1e-6
        or:
        scale < maxzoom + 1e-6
    
    Usage:
    >>> from mapnik import Layer
    >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
    >>> lyr.visible(1.0/1000000)
    True
    >>> lyr.active = False
    >>> lyr.visible(1.0/1000000)
    False
    

    C++ signature :
        bool visible(mapnik::layer {lvalue},double)


Property Details

active

Get/Set whether this layer is active and will be rendered (same as status property).

Usage: >>> from mapnik import Layer >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.active True # Active by default >>> lyr.active = False # set False to disable layer rendering >>> lyr.active False

Get Method:
unreachable(...)
Set Method:
unreachable(...)

buffer_size

Get/Set the size of buffer around layer in pixels.

Usage: >>> print(l.buffer_size) None # None by default >>> l.buffer_size = 2 >>> l.buffer_size 2

Get Method:
unreachable(...)
Set Method:
unreachable(...)

cache_features

Get/Set whether features should be cached during rendering if used between multiple styles

Usage: >>> lyr.cache_features False # False by default >>> lyr.cache_features = True # set to True to enable feature caching

Get Method:
unreachable(...)
Set Method:
unreachable(...)

clear_label_cache

Get/Set whether to clear the label collision detector cache for this layer during rendering

Usage: >>> lyr.clear_label_cache False # False by default, meaning label positions from other layers will impact placement >>> lyr.clear_label_cache = True # set to True to clear the label collision detector cache

Get Method:
unreachable(...)
Set Method:
unreachable(...)

datasource

The datasource attached to this layer.

Usage: >>> from mapnik import Layer, Datasource >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.datasource = Datasource(type='shape',file='world_borders') >>> lyr.datasource <mapnik.Datasource object at 0x65470>

Get Method:
unreachable(...)
Set Method:
unreachable(...)

group_by

Get/Set the optional layer group name.

More details at https://github.com/mapnik/mapnik/wiki/Grouped-rendering:

Get Method:
unreachable(...)
Set Method:
unreachable(...)

maximum_extent

The maximum extent of the map.

Usage: >>> m.maximum_extent = Box2d(-180,-90,180,90)

Get Method:
unreachable(...)
Set Method:
unreachable(...)

maxzoom

Get/Set the maximum zoom lever of the layer.

Usage: >>> from mapnik import Layer >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.maxzoom 1.7976931348623157e+308 # default is the numerical maximum >>> lyr.maxzoom = 1.0/1000000 >>> lyr.maxzoom 9.9999999999999995e-07

Get Method:
unreachable(...)
Set Method:
unreachable(...)

minzoom

Get/Set the minimum zoom lever of the layer.

Usage: >>> from mapnik import Layer >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.minzoom # default is 0 0.0 >>> lyr.minzoom = 1.0/1000000 >>> lyr.minzoom 9.9999999999999995e-07

Get Method:
unreachable(...)
Set Method:
unreachable(...)

name

Get/Set the name of the layer.

Usage: >>> from mapnik import Layer >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.name 'My Layer' >>> lyr.name = 'New Name' >>> lyr.name 'New Name'

Get Method:
unreachable(...)
Set Method:
unreachable(...)

queryable

Get/Set whether this layer is queryable.

Usage: >>> from mapnik import layer >>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.queryable False # Not queryable by default >>> lyr.queryable = True >>> lyr.queryable True

Get Method:
unreachable(...)
Set Method:
unreachable(...)

srs

Get/Set the SRS of the layer.

Usage: >>> from mapnik import layer >>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.srs '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' # The default srs if not initialized with custom srs >>> # set to google mercator with Proj.4 literal ... >>> lyr.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over'

Get Method:
unreachable(...)
Set Method:
unreachable(...)

status

Get/Set whether this layer is active and will be rendered.

Usage: >>> from mapnik import Layer >>> lyr = Layer('My Layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs') >>> lyr.status True # Active by default >>> lyr.status = False # set False to disable layer rendering >>> lyr.status False

Get Method:
unreachable(...)
Set Method:
unreachable(...)

styles

The styles list attached to this layer.

Usage:
>>> from mapnik import layer
>>> lyr = layer('My layer','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
>>> lyr.styles
<mapnik._mapnik.Names object at 0x6d3e8>
>>> len(lyr.styles)
0
 # no styles until you append them
lyr.styles.append('My Style') # mapnik uses named styles for flexibility
>>> len(lyr.styles)
1
>>> lyr.styles[0]
'My Style'

Get Method:
unreachable(...)