Skip to content

Instantly share code, notes, and snippets.

@jaakla
Last active September 29, 2018 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaakla/5a420d3d0527747291f8636846bda077 to your computer and use it in GitHub Desktop.
Save jaakla/5a420d3d0527747291f8636846bda077 to your computer and use it in GitHub Desktop.
Eesti Põhikaardi 1:10000 grid numbri arvutus
# src: https://geoportaal.maaamet.ee/est/Andmed-ja-kaardid/Koordinaatsusteemid-ja-kaardilehtede-jaotused/Kaardilehtede-susteemid-p224.html
# consts for bounds
xmin = 300000
xmax = 800000
square_x = 100000 # 1st level grid size
ymin = 6300000
ymax = 6700000
square_y = 100000
start1 = 4 # grid digit offsets
start2 = 1
start5 = 1
# input data, center of 53833 square
x = 532500
y = 6487500
xrel = x - xmin
yrel = y - ymin
grid10t = str((yrel//square_y) + start1) \
+ str((xrel//square_x) + start2) \
+ str(((yrel % square_y)//10000)) \
+ str(((xrel % square_x)//10000)) \
+ str(2 * ((yrel % square_y)//80000) + ((xrel % square_x)//80000) + start5)
print(grid10t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment