Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Utilities

    pycnik 1.3.2.1

    Download button

    No screenshots available
    Downloads: 152  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Ludovic Delaune | More programs
    GPL v3 / FREE
    September 12th, 2012, 09:25 GMT
    ROOT / Utilities

     Read user reviews (0)  Refer to a friend  Subscribe

    pycnik description

    Tool for generating Mapnik's stylesheets from python code

    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 install


    Testing

    To run the tests:

      python -m unittest discover -s test/

    Getting started

    Pycnik 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_COLOR
    Map.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_RASTER

    bnd = Layer("country boundaries")
    bnd.datasource = DATABASE_PARAM
    bnd.table = "schema.boundaries"

    ########
    # STYLES
    ########
    natural_earth.style()[:3] = {
     RASTER: {
     'scaling': 'bilinear'
     }
    }

    bnd.style("blue")[0:19] = {
     LINE: {
     'fill': 'rgb(255,0,0)',
     'stroke-width': '4'
     },
     'filter': "[countrycode]='ESP'"
    }

    bnd.style("blue")[10:15] = {
     LINE: {
     'stroke-width': '12'
     }
     # inheritance, the filter is conserved
    }


    Generate mapnik XML

     pycnik example.py -o example.xml


    Product's homepage

    Here are some key features of "pycnik":

    · allow using exotic number of zoom levels and tile sizes (computes scales denominators)
    · provides a mechanism for inheritance
    · automatic add cache-feature attribute when using more than 2 styles

    Requirements:

    · Python
    · mapnik2
    · lxml

    Limitations:

    · no possibility to use several similar symbolizers in the same rule

      


    TAGS:

    Mapnik stylesheets | XML stylesheet | Mapnik | XML | stylesheet

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM