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..

  • Mapnik supports rendering shape files directly with OGR plugin. It is recommended to build shape index with shapeindex tool. – Ilja Zverev Jul 18 '14 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 Jul 23 '14 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. – Ilja Zverev Jul 23 '14 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 Jul 24 '14 at 6:01
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.

  • Thanks Dave. I looked after TileMill. But I am specifically more involved in OSM + Mapnik – Aditya Jul 23 '14 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. – Dave Glassborow Jul 24 '14 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 Jul 24 '14 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 – Dave Glassborow Jul 29 '14 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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