1

I'm using ubuntu 12.04. I installed mapnik from packages as described here: https://github.com/mapnik/mapnik/wiki/UbuntuInstallation now I want to run node-mapnik-sample-code from here: https://github.com/mapnik/node-mapnik-sample-code

The example is:

node ./examples/simple/render.js examples/stylesheet.xml map.png

but if I run this command it shows the errormessage

/home/tiletest/node-mapnik/examples/simple/render.js:27
map.loadSync(stylesheet);
    ^
Error: Could not create datasource for type: 'shape'  encountered during parsing of layer 'world' in Layer at line 11 of     'examples/stylesheet.xml'
    at Object.<anonymous> (/home/tiletest/node-mapnik/examples/simple/render.js:27:5)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

do I have to edit the stylesheet.xml or how can I run the example ?

  • I don't know the linked tut, please try to follow the guide at www.switch2osm.org to setup a local OSM rendering stack. Then test it with the local tileserver. If it works you can go further and test the node.js examples. Sorry but I never used node.js, so I can't provide further help :/ – Mapper Mar 4 '14 at 12:22
  • yes you can edit the xml to change the shapefile and its path as you wish. – Below the Radar Mar 4 '14 at 13:35
  • I don't know what should be changed, the path to the shapefile is ok – foobarbaz Mar 4 '14 at 13:54
1

The traceback tell you that the shapefile could not be parsed. The first things to check are:

  1. In stylesheet.xml the datasource is defined by:

    <Parameter name="file">data/world_merc.shp</Parameter>

    Be sure that this shapefile is located in this path in your computer.

  2. Be sure that the mapnik shapefile plugin is well installed by doing:

    $ python -c "from mapnik import DatasourceCache as c; print ','.join(c.plugin_names())"
    

    If you see shape in the list, it's good. Otherwise, you will have to re-install Mapnik with this plugin.

Otherwise, the error could be harder to find and you should probably try following the guide at www.switch2osm.org

|improve this answer|||||
  • I checked the input from the parameter name, the shapefile is located int this path. when executing python -c "from mapnik import DatasourceCache as c; print ','.join(c.plugin_names())" it shows csv,gdal,geojson,ogr,osm,postgis,raster,shape,sqlite so I think the shapefile plugin is available – foobarbaz Mar 4 '14 at 13:46
  • have you built mapnik from github source or did you use apt-get for installation? – Below the Radar Mar 4 '14 at 14:04
  • I used apt-get for installation – foobarbaz Mar 4 '14 at 14:11
  • You can try to run the shapefile_test.py to see if your shapefile plugin works well. If yes, than the problem is probably in node-mapnik-sample-code – Below the Radar Mar 4 '14 at 14:16
  • ok tried it. it prints Traceback (most recent call last): File "shapefile_test.py", line 4, in <module> from nose.tools import * ImportError: No module named nose.tools don't know what's that for a module – foobarbaz Mar 4 '14 at 14:27

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.