3.6. Layer

A layer renders data from a data source using one or more styles.

Table 21. Layer attributes
Attribute Value Default Description

buffer-size

float

0

cache-features

bool

false

On layers with multiple styles: read features from data source only once and cache them in memory. Improves performance, but at the cost of using more memory, so off by default.

comp-op

string

src-over

See Compositing

clear-label-cache

bool

false

Clear the placement cache from previous layers, so that texts, points and markers may overlap with those from previous layers.

group-by

string

none

On layers with multiple styles these styles are processed one by one in the given order by default. With group-by, features are instead processed in groups of consecutive features having the same value in the given column: all styles are applied to the first group, then all styles to the next group, and so on. Features are not sorted for this, a new group starts whenever the value changes from one feature to the next, in the order the data source returns them. E.g. with group-by="z" and data ordered by z from -1 to 1, first all features with z=-1 are processed using all styles, then all with z=0, and finally all with z=1. If the data is not ordered by the column, sort it in the data source query, e.g. with ORDER BY in a PostGIS query; combining group-by with sort-by does not work, group-by is ignored then.

minimum-scale-denominator

float

0

Minimum map scale above which this layer should be rendered.

maximum-extent

4x float

Maximum extent for which features should be processed.

maximum-scale-denominator

float

max. float

Maximum map scale up to which this layer should be rendered.

name

string

none

Name by which the layer can be referenced, e.g. for error messages.

opacity

float

1.0

opacity of the layer towards already rendered lower layers and the <Map> background

queryable

bool

false

unused?

sort-by

string

none

Sort the layer’s features by this column before rendering, ASC (default) or DESC. Later features are drawn on top of earlier ones, earlier features win label placement collisions. (since Mapnik v4.1.4)

srs

SRS string

epsg:4326

Spatial reference system

status

boolean

true

Whether this layer should actually be processed or not. Caution: when set to false in XML the complete <Layer> will simply be skipped on reading the style file, and no layer object will be created for it. So you won’t be able to enable such a layer with Layer.set_status(true) using API code later.

Example 13. Layer
<Layer name="layer_1">
  <StyleName>style_1</StyleName>
  <StyleName>style_2</StyleName>

  <DataSource>
    [...]
  </DataSource>
</Layer>