mapnik-render reports "Error Not a map file. Node 'Map' not found." on OpenStreetMap maps
MarioTrams opened this issue · comments
Hello,
I wanted to try to render a map using the command-line "mapnik-render" tool. However, it is telling me always
Error Not a map file. Node 'Map' not found.
I'm using this under Ubuntu 20.04 and the version of mapnik-render is 3.0.23 (shown by mapnik-render -V).
I'm calling this like:
mapnik-render --xml andorra-latest.osm --img test.png
andorra-latest.osm was just a (small) original map I used for testing. I tried also maps exported from the OpenStreetMap website or extracted via osmosis. It's never working. For big maps it's eating up gigabytes of data only to tell me this error message.....
Any ideas?
Thanks,
Mario
Normal, you are mixing things. You provide an input with XML from datasource (an OSM file) whereas you should provide an XML with Mapnik XML file. As you can see in my sample, there is a Map
block whereas the osm file does not contain this block hence the error you mentioned
Error Not a map file. Node 'Map' not found.
A minimum recipe that works
wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip
unzip ne_10m_admin_0_countries.zip
echo '<?xml version="1.0" encoding="utf-8"?>
<Map srs="+init=epsg:4326">
<Style name="Default Style">
<Rule>
<PolygonSymbolizer fill="#f2eff9" />
<LineSymbolizer stroke="rgb(50%,50%,50%)" stroke-width="0.1" />
</Rule>
</Style>
<Layer name="world" srs="+init=epsg:4326">
<StyleName>Default Style</StyleName>
<Datasource>
<Parameter name="file">ne_10m_admin_0_countries.shp</Parameter>
<Parameter name="type">shape</Parameter>
<Parameter name="encoding">utf-8</Parameter>
</Datasource>
</Layer>
</Map>' > demo.xml
# Below line due to issue with https://github.com/mapnik/mapnik/issues/4010
# Fix with trick from https://github.com/jawg/docker-mapnik3/issues/2#issuecomment-656823293 to make output works
mkdir -p plugins && ln -s $(mapnik-config --input-plugins) plugins/input
mapnik-render demo.xml out.png
Ok, thanks! I got the point. There is some wrapper needed that is linking the actual map. The example is working for me. Obviously there are some more changes needed in order to process OpenStreetMap maps, but I'm one step further.....
@MarioTrams if you want to render osm tiles, look into https://switch2osm.org/serving-tiles/manually-building-a-tile-server-20-04-lts/ and https://github.com/gravitystorm/openstreetmap-carto
@mathisloge Thanks! I'll check that.