mapnik · GitHub

Mapnik configuration XML

See also a reference PDF created by David Eastcott (written for 0.7)

General

Comments can be placed in the file using the default xml <!-- --> syntax

Basic usage: a Map consists of Styles defined in Rules, and Layers apply those Styles by name to Datasources such as a Shapefile:

<Map background-color="white" srs="+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.06,0.1502,0.247,0.8421,-20.4894 +units=m +no_defs">
  <Style name="TidalWater_FullColour">
    <Rule>
      <MinScaleDenominator>1000</MinScaleDenominator>
      <MaxScaleDenominator>25000</MaxScaleDenominator>
      <PolygonSymbolizer fill="#D5F4F8"/>
    </Rule>
  </Style>
  <Layer>
    <StyleName>TidalWater_FullColour</StyleName>
    <Datasource>
      <Parameter name="file">./OS-VectorMap-District/st/ST_TidalWater.shp</Parameter>
      <Parameter name="type">shape</Parameter>
    </Datasource>
  </Layer>
</Map>

<Map>

  • Element type: The master object of a Mapnik configuration XML. Has map-wide parameters and serves as the container for Styles and Layers.

  • Attributes (in alphabetical order):

    • "background-color"= HTML color code for the background-color of the map (for instance #000000)
      • was "bg-color"= prior to Mapnik2.
      • Opacity is controlled by the last two digits of an 8-digit value. #00000000 means transparent background. The default value is #000000FF.
    • "background-image"= Available in Mapnik2: use an image for the background instead of a color fill.
    • "buffer-size"= Default 0; Good value is usually tile size/2 to help avoid cut labels. This influences envelope used by placement detector ( i.e. 'avoid_edges' parameter). Also set maximum-extent, otherwise you will get problems for bboxes near the borders of your map.
    • "font-directory"= Available in Mapnik2: pass a directory that contains fonts, which will automatically be registered if they end in ttf, otf, ttc, pfa, pfb, ttc, or dfont.
    • "maximum-extent"= Set to maximum extent of (projected) map, ie. in coordinates of result map. For instance "-20037508.34, -20037508.34, 20037508.34, 20037508.34". See also BoundsClipping.
    • "minimum-version"= Declare the minimum version of mapnik to be used with the stylesheet. Example: minimum-version="0.6.1". Will print a notice if you use an older mapnik version.
    • "paths-from-xml"= Check if relative paths should be interpreted as relative to/from XML location (default is true)
    • "srs"= Coordinate system in which the map is rendered (for instance '+proj=latlong+datum=WGS84' for a WGS84 Geographic coordinate system)
  • Children:

    • <Datasource> See also 37f49e2

    • <FileSource>: See 37f49e2

    • <FontSet>: Defines a fontset for fallback fonts (if a character isn't found in the first font, proceed through the list until it is found)

    • <Include>: The container tag used to wrap all context in files included via XInclude

    • <Layer>

    • <Style>

    • xmlcomment: (Ignored by Mapnik)

    • xmlattr: (Ignored by Mapnik)

<Style>

"Permalink:

Read the original on github.com ↗