Last active
December 27, 2017 02:12
-
-
Save Fingel/97cf4cc0a0cb0a07477a521906f582ae to your computer and use it in GitHub Desktop.
Return the SRID corresponding to the UTM zone for a given Latitude and Longtitude in WSG84
This file contains 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
""" | |
Point must be in srid 4326 (Mercator projection) | |
Based on http://lists.osgeo.org/pipermail/postgis-users/2005-December/010204.html | |
""" | |
def point_to_srid(lat, lng): | |
if lat > 0: | |
base_srid = 32600 # northern hemisphere | |
else: | |
base_srid = 32700 | |
utm = floor((lng + 186) / 6) | |
return base_srid + utm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment