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

I'm creating a web interface where users click on a map to denote a point of interest. My application then returns all items in a database that lie within a specified distance of that point. I'm only concerned with UK (I mention this in case there's a good approximation available) and primarily working with zoom=9.

AIUI, each tile covers a certain angle of latitude and longitude rather than distances over the ground. Thanks to the information in this wiki article, I can calculate the distance between the top-left corners of adjacent tiles (and hence derive the distance over the ground for any tile), but that seems rather messy.

asked 08 Oct '10, 14:12

Pajaholic's gravatar image

Pajaholic
61114
accept rate: 0%


If you are happy with an approximation then think about this:

  • At zoom level 9, your world has 2^9 by 2^9 tiles (that's 512x512 tiles).
  • The Earth's circumference is roughly 40,000 kilometres.

Thus:

  • For the y axis, you have 20,000 km from North Pole to South Pole, divided by 512, that's roughly 39 km for the height per tile. (The 512x512 tiles don't exactly stretch all the way to the poles, only to the 85° line, but we can ignore that for this approximation.) This tile height is the same everywhere.
  • For the x axis it is not quite so easy because the number of kilometres used by the 512 tiles is different depending on where you are - 40,000 km at the Equator, 25,000 at the latitude of the Scilly Isles, and 20,000 at the latitude of Unst. So it's fair to use 22,500 as an approximation for the UK; divide that by 512 and you end up at a tile width of roughly 44km.

Or very roughly: A zoom level 9 tile in the UK has 40x40km. (Double the width/height when you decrement the zoom level, halve the width/height when you increment.)

permanent link

answered 08 Oct '10, 19:56

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

edited 11 Oct '10, 08:59

You can calculate it yourself, based on this wiki page:

resolution = 156543.034 meters/pixel * cos(latitude) / (2 ^ zoomlevel)

The resolution means how many meters per pixel you get. If you want to know how many pixels per meter, just use the inverse. That is:

pixels = 1/resolution * distance

And if you want to calculate the scale (to write it on the map for printing it):

scale = 1 : (dpi * 39.37 in/m * resolution)

The scale means, how many cm in reality is 1 cm on the paper (or on the screen).

So if you have a screen with 96 dpi, you get that one pixel is 1.1943 meters. And you get a scale of 1 : 4 231 which means that 1 cm on your screen is 42.3 m in reality.

If you have a printer which prints 300 dpi … (now do the calculations yourself).

permanent link

answered 14 Feb '14, 12:10

erik's gravatar image

erik
558152234
accept rate: 9%

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:

×144
×57
×23

question asked: 08 Oct '10, 14:12

question was seen: 22,865 times

last updated: 14 Feb '14, 12:10

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