Skip to content

Commit

Permalink
dynamic latitude in map scale calc
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbcode committed Jul 7, 2023
1 parent bb5efde commit e7a5198
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions geemap/geemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,13 @@ def get_scale(self):
import math

zoom_level = self.zoom
# Reference: https://blogs.bing.com/maps/2006/02/25/map-control-zoom-levels-gt-resolution
resolution = 156543.04 * math.cos(0) / math.pow(2, zoom_level)
center_lat = self.center[0]

# Reference:
# - https://blogs.bing.com/maps/2006/02/25/map-control-zoom-levels-gt-resolution
# - https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Resolution_and_Scale
center_lat_cos = math.cos(math.radians(center_lat))
resolution = 156543.04 * center_lat_cos / math.pow(2, zoom_level)
return resolution

getScale = get_scale
Expand Down

0 comments on commit e7a5198

Please sign in to comment.