NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi, Thanks to the help of some nice people on this forum I got nik2img working.

Still the images go far over the bounding box values.

nik2img.py mapnik.xml mercator1.png --srs 900913 --bbox 4 51 6 54 -d 1500 1500 -v

nik2img.py mapnik.xml mercator2.png --srs 900913 --bbox 4 51 6 54 -d 500 500 -v

The images start at app 2 long and reach to appr 8 long. Bottom seems valid. Top to low. This makes navigation impossible. Is there a way to really fix these borders on bbox values? Thanks.

asked 25 Feb '14, 22:42

wim%20de%20vries's gravatar image

wim de vries
31224
accept rate: 0%

closed 26 Feb '14, 23:12

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554

The question has been closed for the following reason "The question is answered, accepting own answer is not possible here. So... closing." by aseerel4c26 26 Feb '14, 23:12


The problem arises because the dimensions of your image are square, while the projected dimensions of the bounding box are not (the rectangle you are asking to draw is more than twice as high than it is wide).

If you ask Mapnik (nik2img) to put a rectangle that is much higher than wide into a square output file, it will add stuff to the east and west that you haven't asked for. Actually nik2img should tell you the box it has decided to draw in -v mode. Read the output.

For a bbox of "4 51 6 54", you have to specify the dimensions "1500 3698" (or "500 1233") to get an image that exactly contains your bounding box.

See also the --aspect-fix-mode option of nik2img which allows you to control what happens when bounding box and image dimensions do not match.

If you want an output file that has the same aspect ration as the bounding box in degrees (e.g. you enter a box that is 2 degrees wide and 2 degrees high and you want a square output file) then you have to choose --srs 4326.

permanent link

answered 26 Feb '14, 07:18

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

edited 26 Feb '14, 07:20

Thanks for your answer. I do see an output line:

Step: 11 // --> Map long/lat bbox: Box2d(2.53474181678,51.0,7.46525818322,54.0)

I presume that is the notification of stretching it up.

I am still puzzled about the image sizes you mention. In the past I have used (downloaded) OSM maps (scale ~1:500000), but there the img height depends on which latitude you are on, while all x values having the same nr of pix size. This made navigation possible using the OSM equations (http://wiki.openstreetmap.org/wiki/Mercator).

So, I want to say to nik2img: let one longitude be 795 pix; make a map like above (--bbox 4 51 6 54) with width 2x795 pix and height .... calculate it for I don't know.

Do you think this would be possible?

(26 Feb '14, 11:10) wim de vries

The answer is --aspect-fix-mode=GROW_CANVAS

permanent link

answered 26 Feb '14, 12:19

wim%20de%20vries's gravatar image

wim de vries
31224
accept rate: 0%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×30
×2

question asked: 25 Feb '14, 22:42

question was seen: 3,441 times

last updated: 26 Feb '14, 23:12

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum