Turbo87 / utm

Bidirectional UTM-WGS84 converter for python
http://pypi.python.org/pypi/utm
MIT License
486 stars 101 forks source link

Feature request: return the EPSG code corresponding to the UTM zone #51

Open araichev opened 4 years ago

araichev commented 4 years ago

I'd use that feature.

rabbl commented 4 years ago

I'd love that feature too.

araichev commented 4 years ago

Aha, it's easier than i initially thought:

def utm_epsg_from_latlot(lat, lon):
    zone = utm.from_latlon(lat, lon)[2]
    return f"326{zone:02d}"
rabbl commented 4 years ago

you should make a difference between northern and southern hemisphere:

32633 for zone 33 northern hemisphere 32733 for zone 33 southern hemisphere

So the method could be something like this:

def utm_epsg_from_latlot(lat, lon):
    zone = utm.from_latlon(lat, lon)[2]
    return f"326{zone:02d}" if lat >= 0 else f"327{zone:02d}"
rico-ci commented 4 years ago

Yeah, this is discussed on several platforms (e.g. here). It would be great to have this as part of the package, so +1 on this issue.