[GIS] Mapnik generate_tiles.py error using .xml from TileMill

mapnikrenderingtilemill

I wanted to render PNG tiles (like form tile server of OSM). I made PostGIS db, successfully run TileMill with OSMBright style. I read that I need now export Mapnik XML from TileMill. I checked Mapnik as in Python tutorial and everything works fine.

I've changed generate_tiles.py:

  • changed the .xml file to read
  • changed the bbox (I have checked bbox of small area while exporting to PNG in TileMill)
  • changed the render line to render_tiles(bbox, mapfile, tile_dir, 15, 16 , "mymap")

but an error occurs:

Failed to load fonts from: ./fonts in Map at line 3 of '/home/myacc/bin/mapnik/osm.xml/'

I think the .xml is not made properly (it has written path as reference to current path) but maybe I am wrong.

My questions:

  1. I am doing it wrong (generate XML from TileMill, put it into ~/bin/mapnik and changing generate_tiles.py)?

  2. Is there a better way to make these tiles?

  3. If not- what I should do to make this work (where are those fonts it can't find (I think there will be more errors with reading files) )

    edit 1

I have checked:

python -c "import mapnik;print mapnik.fontscollectionpath"

and changed the fontpath in osm.xml, but there is no such fonts registered by Mapnik . I printed out known fonts by:

python -c "from mapnik import FontEngine as e;print '\n'.join(e.instance().face_names())"

but there isn't a font face 'Free Sans Semibold'

Best Answer

You obviously have to download fonts from the github repo and place them in the fonts subdirectory near osm.xml. If they are not found, put them somewhere mapnik could find them. The original OSMBright style was obviously made to be used from the style directory.

OSMBright repository doesn't have any references to "Free Sans", you must have mistyped.

Also, I'd recommend more intelligent way of producing tiles: polytiles.py.