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

Hi, I’m preparing some maps using Maperitive for projects in print, e.g. my personal travel photobook and a travel guide to be published.

I got the conversion OSM-SVG-PDF working, but I need my (PDF) maps in defined sizes, e.g.

  • show the surroundings of some sight in 1:5000 in a picture of 5x5cm
  • show a whole country, state or city on a book/A4 page

That means, my output size is fixed, I can also set the scale, and I have either a pair of coordinates that must be included, or I have one coordinate to be the center point.

I don’t really care about the used projection (I wouldn’t know which one to choose anyway) and would use the default one of Maperitive.

But I need an algorithm to calculate the coordinates to use in Maperitive’s "set-print-bounds-geo" from output size, scale and a center point OR from output size and an included pair of coordinates. I’ll implement that in a Python script (and possibly in a spreadsheet). If some guesswork is involved, I'll just try a loop for approximation.

Please don’t just send me to Geoinformatics 101 ;)

EDIT: Trying to reword my question: As far as I understand, OSM data is in WGS84. Now, if I need a map of e.g. 5x5km around a coordinate, how much are these 2.5km plus/minus in easting/northing? Does it depend on the actual place?

asked 16 Aug '15, 04:31

Hraban's gravatar image

Hraban
1864610
accept rate: 0%

edited 16 Aug '15, 14:45

Another try at rewording: How do I add some length on the map to a longitude or latitude? (The length on the surface is not the same as the length in a projection, is it?) I found the formulae of Mercator projection in Wikipedia, but I don’t understand how to employ them – if they’re a solution for my problem at all.

(16 Sep '15, 09:39) Hraban

Not sure about Maperitive's setup but I did something similar a while back using Mapnik. In that you specify the scale per pixel as it is generally setup for output to displays. But once you decide the number of dots per inch (or cm) you are going to be printing at and the map scale you want the printed page to be you can multiply the numbers out to get the scale per pixel you need. In my case I have some scripts where I specify the center point for the map, the printed scale I want (usually 1:24000) and the size of the paper I am printing too. Here is a bit of out of context python code where I do my calculations. (Associate array v contains a definition of the map I want to print (paper size, map center in UTM grid coordinates, etc.) while things like the print dots per inch are specified as arguments on the command line). I specify my text in terms of printer points (72dpi) so I calculate what the DPI on those should be too:

image_width = int(round(v['width'] * args.dpi))
image_height = int(round(v['height'] * args.dpi))

pixels_per_point = args.dpi / 72.0;
meters_per_pixel = 0.0254 * v['scale'] / args.dpi
meters_per_point = meters_per_pixel * pixels_per_point

top = int(round((meters_per_pixel * (image_height / 2)) + int(v['northing'])))
bottom = int(round((meters_per_pixel * (-image_height / 2)) + int(v['northing'])))
left = int(round((meters_per_pixel * (-image_width / 2)) + int(v['easting'])))
right = int(round((meters_per_pixel * (image_width / 2)) + int(v['easting'])))

bot_left= wgs84utm(left, bottom, inverse=True);
top_right = wgs84utm(right, top, inverse=True)

I have another hacked up script that puts my output raster image file into a PDF so I can easily force printing at the desired DPI by just telling the print dialog box to print at 100% but that is probably outside of the scope of your question.

permanent link

answered 16 Aug '15, 12:33

n76's gravatar image

n76
10.8k1082172
accept rate: 17%

Thanks for trying, but you misunderstood - I'm not interested in pixels at all, since I deal with vector data. What I need is your "wgs84utm" function. Seems like it comes from http://gis.stackexchange.com/questions/78915/off-by-about-85-meters-when-converting-nad27-utm-to-wgs84-lat-lon, i.e. from pyproj. That’s a good hint, even if I’d like to avoid external libraries. The remaining geometric calculations maybe useful, too (but those I would have been able to cook up myself).

EDIT: The pyproj (i.e. proj.4) docs are too much for me. :(

(16 Aug '15, 14:11) Hraban

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:

×48
×20
×14

question asked: 16 Aug '15, 04:31

question was seen: 3,571 times

last updated: 16 Sep '15, 09:39

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