TransWikia.com

Convert UTM zone into EPSG code

Geographic Information Systems Asked by Andrew Einhorn on December 2, 2020

I have the UTM code 36S and want to convert it to EPSG.

Somebody told me that if the UTM code contains ‘S’, then the first three digits of the EPSG code are 327, and if the UTM code is ‘N’ then use 326 instead. And then you just append the UTM number (in this case 36) to get ‘327’ + ’36’ => ‘32736’.

Does this always work? And should I be using some python library to do this for me?

3 Answers

Use pyproj (version 2.2+):

from pyproj import CRS

# use PROJ string, assuming a default WGS84
crs = CRS.from_string('+proj=utm +zone=36 +south')
# or dictionary
crs = CRS.from_dict({'proj': 'utm', 'zone': 36, 'south': True})

print(crs.to_authority())  # ('EPSG', '32736')

Correct answer by Mike T on December 2, 2020

In Python, You can use osr, which comes with gdal:

import osr

zone = '36'
south = True

epsg_code = 32600
epsg_code += int(zone)
if south is True:
    epsg_code += 100

print (epsg_code) # will be 32736

spatref = osr.SpatialReference()
spatref.ImportFromEPSG(epsg_code)
wkt_crs = spatref.ExportToWkt()
print (wkt_crs) 

Answered by Johan on December 2, 2020

Thanks @Johan, your code is very usefully.

I need to find the EPSG id for utm zone, given latitude and longitude :

import math
# Special zones for Svalbard and Norway
def getZones(longitude, latitude) :
    
    if (latitude >= 72.0 and latitude < 84.0 ) :
         if (longitude >= 0.0  and longitude <  9.0) :
              return 31              
    if (longitude >= 9.0  and longitude < 21.0):
          return 33
    if (longitude >= 21.0 and longitude < 33.0):
          return 35
    if (longitude >= 33.0 and longitude < 42.0) :
          return 37
    return (math.floor((longitude + 180) / 6) ) + 1 
    

def findEPSG(longitude, latitude) :
    
    zone = getZones(longitude, latitude)
    #zone = (math.floor((longitude + 180) / 6) ) + 1  # without special zones for Svalbard and Norway         
    epsg_code = 32600
    epsg_code += int(zone)
    if (latitude < 0): # South
        epsg_code += 100    
    return epsg_code
    
    
print(findEPSG(-64,-32)    )

Answered by user2232395 on December 2, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP