pycnik

Tool for generating Mapnik's stylesheets from python code
Download

pycnik Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL v3
  • Price:
  • FREE
  • Publisher Name:
  • Ludovic Delaune
  • Publisher web site:
  • https://github.com/ldgeo/

pycnik Tags


pycnik Description

pycnik is a simple Translator from Python code (with coding conventions) to Mapnik XML stylesheet.Install Pycnik git clone https://github.com/ldgeo/pycnik cd pycnik python setup.py installTestingTo run the tests: python -m unittest discover -s test/Getting startedPycnik use dynamic variable declaration, so you have to use the same keywords as the xml declaration syntax.example.py:from pycnik.model import *BACKGROUND_COLOR = 'rgb(255,255,220)'NATURAL_RASTER = { "type": "gdal", "file": "natural_earth.tif"}DATABASE_PARAM = { "dbname": "database", "estimate_extent": "true", "host": "0.0.0.0", "password": "******", "port": "5432", "type": "postgis", "user": "mapuser", "srid": "4326",}################# MAP DEFINITION################Map.background_color = BACKGROUND_COLORMap.srs = "+init=epsg:4326"Map.minimum_version = "2.0"Map.font_directory = "fonts"Map.buffer_size = 128######### LAYERS########natural_earth = Layer("natural_earth")natural_earth.datasource = NATURAL_RASTERbnd = Layer("country boundaries")bnd.datasource = DATABASE_PARAMbnd.table = "schema.boundaries"######### STYLES########natural_earth.style() = { RASTER: { 'scaling': 'bilinear' }}bnd.style("blue") = { LINE: { 'fill': 'rgb(255,0,0)', 'stroke-width': '4' }, 'filter': "='ESP'"}bnd.style("blue") = { LINE: { 'stroke-width': '12' } # inheritance, the filter is conserved}Generate mapnik XML pycnik example.py -o example.xmlProduct's homepage


pycnik Related Software