I'm assuming you're using the google-style spherical mercator
projection,
http://spatialreference.org/ref/epsg/3785/ ?
To do the conversion, you need to know the width of the projection in
meters and in pixels. I've always had a bit of a problem with this,
because in a projection like Mercator, meters and "meters" are only
the same thing at the equator, and grow progressively more different
the further from that you get. For a typical city in the US or Europe,
the scale used by mapnik bears little relationship to the actual scale
of the stuff of the map, and it's further confounded by the necessary
assumption of a given print resolution.
Anyway.
The raw projection doesn't vary, it's always pi * 2 * 6378137 =
40075017, determined by the radius of the earth in the projection
parameters.
The size of an individual pixel is based on a magic number from the
world of print - I think it's 90ppi or thereabouts? Dane? At 90ppi,
the number of meters per pixel is given by 0.0254 meters per inch / 90
pixels per inch = 0.000282 meters per pixel. In other words one pixel,
when printed at 90ppi, is about 0.28mm across.
This is the part that varies based on zoom level: the pixel width of
the projection is 2 ^ (zoom + 8), so 67108864 pixels at zoom 18,
4194304 pixels at zoom 14, 262144 pixels at zoom 10, down to 256
pixels at zoom 0. The 8 is there in the exponent because tiles are 2^8
pixels wide.
So the scale denominator is 40075017 / (0.000282 * pixel width of
projection) = 2116 at zoom 18, 33855 at zoom 14, 541683 at zoom 10, up
to 554684413 at zoom 0. I'm still not sure about that magic 90ppi
number, but when it does seem to fit with the very rough ranges I use
in Cascadenik:
# somewhat-fudged values for mapniks' scale denominator at a
range
# of zoom levels when using the Google/VEarth mercator
projection.
zooms = {
1: (200000000, 500000000),
2: (100000000, 200000000),
3: (50000000, 100000000),
4: (25000000, 50000000),
5: (12500000, 25000000),
6: (6500000, 12500000),
7: (3000000, 6500000),
8: (1500000, 3000000),
9: (750000, 1500000),
10: (400000, 750000),
11: (200000, 400000),
12: (100000, 200000),
13: (50000, 100000),
14: (25000, 50000),
15: (12500, 25000),
16: (5000, 12500),
17: (2500, 5000),
18: (1000, 2500)
}
On Nov 4, 2009, at 11:00 PM, Balram wrote:
----------------------------------------------------------------
michal migurski-
mike@...
415.558.1610
_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users