4

I am new to GIS.

I have a Shapefile (.shp, .shx and .pbf). The .pbf file contains path to PNG files located on my machine only. I was able to save the Shp data to PostGis via Shape2Gis tool.

Now that a tables are created with PostGIS. How can I use this table to show data with Mapnik? I am using Mapnik + OpenStreetMap and Mod_tile.I have been previously using osm2pgsql and the maps are being rendered. I have a shapefile, shx file and pbf file. Not sure how to use it to render maps..

4
  • Mapnik supports rendering shape files directly with OGR plugin. It is recommended to build shape index with shapeindex tool. Commented Jul 18, 2014 at 12:18
  • Thanks Ilja for the reply. I went through the plugin. But not sure how to use it for rendering maps. I mean where should I create the xml file? Would it fetch that file runtime?
    – Aditya
    Commented Jul 23, 2014 at 10:16
  • You just create a layer inside you regular mapnik xml with datasource type "ogr". To understand and apply that, you need to learn Mapnik XML format — or just use TileMill, like Dave recommends, it supports shape files out of the box and is based on mapnik renderer. Commented Jul 23, 2014 at 14:22
  • Thanks Ilja, I updated the layer-shapefiles.xml.inc with required xml as follows with the path of my shapefile. <Layer name="lebanon-latest-buildings" status="on"> <StyleName>lebanon-latest-buildings</StyleName> <Datasource> <Parameter name="type">shape</Parameter> <Parameter name="file">&world_boundaries;/lebanon-latest.shp/buildings.shp</Parameter> </Datasource> </Layer> PS: I also tried OGR. But it does not seem to render anything on map.
    – Aditya
    Commented Jul 24, 2014 at 6:01

1 Answer 1

2

I would start with TileMill, some excellent open source software. This will allow you to design maps, pulling data from shape files, postgis, etc, and render then via Mapnik to various different formats.

TillMill is used by the OSM project for rendering their tiles. TillMill has a form of CSS for designing maps, called CartoCSS, and this is used to design their maps. See https://github.com/gravitystorm/openstreetmap-carto for the official repo. If you follow their instructions, you'll end up with a TillMill project that contains the all the layers of OSM data (and the SQL used to extra it from the Planet PostGIS db). You can then remove what you don't need, and add your own shape files in on top.

Good luck.

4
  • Thanks Dave. I looked after TileMill. But I am specifically more involved in OSM + Mapnik
    – Aditya
    Commented Jul 23, 2014 at 10:17
  • TillMill is a general tool. So I have got OSM data in PostGIS, pulling it into Tillmill, which then renders it using Mapnik. You can export your settings as a Mapnik xml style fill. Tillmill is what is actually used for designing the Openstreetmap.org tiles. Commented Jul 24, 2014 at 11:45
  • Thanks a lot Dave. Appreciate your comments. But even when I export xml data from tilemill, what is the exact process to use it with Mapnik?
    – Aditya
    Commented Jul 24, 2014 at 12:58
  • Use the Mapnik xml style file to render mapnik tiles using various different tools. Maybe this will help: gis.stackexchange.com/a/48290/34871 Commented Jul 29, 2014 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.