2

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?

  • 4
    The above recipe is valid for WGS 84. There are several other UTM 36 zones, see epsg.io/?q=utm+36s – TomazicM Jun 22 at 10:17
4

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')
| improve this answer | |
0

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) 
| improve this answer | |
0

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)    )
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.