2

Hi I am trying to render mine postgis data into Mapnik , but not being able to do the same, Can any one share with me the Python file for the same , which explanes how to do the same.

Manish Sharma

manish sharma
  • 21
  • 1
  • 3

1 Answers1

1

Google is your friend, but here's a quick sample using mapnik 2.1 python and xml styling: Here's the python:

#!/usr/bin/python
import mapnik
from mapnik import Coord, Box2d

###
# Configuration
###
style = 'style.xml'
output = 'output.png'

width = 800
height = 800

bbox = Box2d(-11823891.0314,4847942.08196,-11774971.3333,4896861.78006)
print "Using mapnik version:", mapnik.mapnik_version()
map = mapnik.Map(width, height)
mapnik.load_map(map, style)

map.zoom_to_box(bbox)
mapnik.render_to_file(map, output)

And here's a simple style.xml using osm data:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>

<Map background-color="#FFF">

<Style name="roads">
  <Rule>
    <LineSymbolizer stroke="red" stroke-width="1" />
  </Rule>
</Style>

<Layer name="roads" status="on">
  <StyleName>roads</StyleName>
  <Datasource>
    <Parameter name="table">
      (select way from osm_line where highway is not null) as road
    </Parameter>
    <Parameter name="type">postgis</Parameter>
    <Parameter name="port">5432</Parameter>
    <Parameter name="user">gisuser</Parameter>
    <Parameter name="dbname">gis</Parameter>
  </Datasource>
</Layer>
</Map>
rcarver
  • 963
  • 9
  • 13