OpenStreetMap

Nik4: mapnik → image

Posted by Zverik on 16 May 2014 in English (English)

I recently needed to create a big georeferenced image from a mapnik style file, and found out no image exporting tool currently offers more than a direct interface to mapnik's options. That is, I could not get "image in 300 dpi for printing on an A5 sheet", I had to understand what scale_factor is, and what is the default resolution, and why lines had become so thick. And I'm a programmer — imagine a confusion of a regular user!

Today I have published Nik4. It makes everything easier.

Grab a 800x600 image at z13? -c LON LAT -x 800 600 -z 13 — and no suprises like when the output image differs from osm.org (nik2img puzzled me with that one). Print a region in 300 dpi on A5? -a 5 --ppi 300 --bbox X1 Y1 X2 Y2. You don't have to think about scale_factor ever. Make a very large image? No problem, use --tiles 4 and wait a bit; you won't run out of memory.

See https://github.com/Zverik/Nik4 for an extensive description and installation instructions (easy_install nik4 — there, no more instructions needed). Print more maps.

And for generating tiles there is just as simple polytiles.py.

Comment from stephan75 on 16 May 2014 at 15:32

Hello Zverik, have not tried your new tool yet, but I am really curious!

I also created a stub article in the OSM wiki: http://wiki.openstreetmap.org/wiki/Nik4

Feel free to fill it with better styled information for OSM users.

Now there are also wiki links to Nik4 article from "OSM on Paper" article and Mapnik article in our wiki there.

Hide this comment

Comment from Zverik on 16 May 2014 at 19:05

Thanks! I've restructured the stub page a bit. For now I don't know what to add there, besides links to the announcement and github. We'll see.

Hide this comment

Comment from Rostranimin on 10 June 2014 at 21:06

My suggestion would be to add some text directed at the ordinary OSM user/mapper. I'm one of those :-) I understand what Mapnik is, I understand the basic challenges of getting OSM mapping into a georeferenced image, I'm a pretty experienced mapper (years of involvement). BUT I don't have enough information here to understand whether this is something useful to me. This isn't a criticism - I realise there is a lot still to learn and that the onus is on me to do this - but some plain English words explaining what to you are utterly obvious things would help people like me (to whom they aren't obvious). Note that I'm not asking for more than a few sentences - that should be enough. Thanks.

Hide this comment

Comment from Zverik on 10 June 2014 at 21:16

Rostranimin, thanks for your suggestions. Of course I'm writing from a position of a skilled programmer who's spent some days struggling with Mapnik and most of tools surrounding it. It's very hard to change my point of view :)

The task is quite simple: getting a raster (or vector) image of a map. Currently there are two options: download tiles (256×256 images that web maps are built from) and stitch them (just a bit harder than making a screenshot, see BigMap), or load OSM data into PostgreSQL, install Mapnik and make it render an area for you. Since Mapnik is a library, not a user-oriented program, you need an external tool to which you feed geographic bounds and image size. Nik4 is such tool: basically, after going through all steps to install and load everything, you can switch your brain off and just feed Nik4 numbers, or even URLs, and it would give you images.

Georeferencing is just an icing; most users don't need that. Just making plain images of maps was a hard task — before Nik4.

Hide this comment

Leave a comment

Parsed with Markdown

  • Headings

    # Heading
    ## Subheading

  • Unordered list

    * First item
    * Second item

  • Ordered list

    1. First item
    2. Second item

  • Link

    [Text](URL)
  • Image

    ![Alt text](URL)

Login to leave a comment