Created
November 9, 2020 13:37
-
-
Save BishopGIS/b7cf7d8e86b21ab80754664e274f7e40 to your computer and use it in GitHub Desktop.
Test scale to zoom conversion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import math | |
| dpi = 1000 / 39.37 / 0.28 | |
| ipm = 39.37 | |
| metersPerTile = 156543.04 | |
| def getZoomFromScale(scale): | |
| return math.log(scale) / math.log(2) | |
| def getResolutionForScale(scale, mpu = 1.0): | |
| return scale / (mpu * ipm * dpi) | |
| for scale_mult in range(6): | |
| scale = 1000 * math.pow(10, scale_mult) | |
| res = getResolutionForScale(scale) | |
| zoom = getZoomFromScale(metersPerTile / res) | |
| print('{} [{}] - {}'.format(scale, res, zoom)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment