TransWikia.com

Creating Generic Transverse-Mercator projection in ArcPy with ArcMap

Geographic Information Systems Asked by danielm on June 25, 2021

I’m attempting to create a Transverse-Mercator projection in arcpy. However I keep running into an error trying to set the latitudeOfOrigin, even when the documentation explicitly says this is a required attribute. I am using ArcMap 10.5.

I’ve tried creating the projection from scratch and tried simply modifying the parameters on an existing spatial reference. In both cases I get the following error when trying to set latitudeOfOrigin:

NameError: The attribute ‘latitudeOfOrigin’ is not supported on this
instance of SpatialReference.

What is the proper way to create this projection?

#create from scratch
def test_spatial2(self, lat, lon):
    sr = arcpy.SpatialReference()
    sr.projectionCode = 43006
    sr.projectionName = 'Transverse_Mercator'
    sr.type = "Projected"
    sr.linearUnitCode = 9001 #meters
    sr.gcs = arcpy.SpatialReference(4326) #WGS 84
    sr.scaleFactor = 1
    sr.centralMeridian = lon
    sr.centralMeridianInDegrees = lon
    sr.latitudeOfOrigin = lat
    sr.falseEasting = 0
    sr.falseNorthing = 0
    sr.create()

#create from UTM
def test_spatial3(self, lat, lon):
    sr = arcpy.SpatialReference(32610) #WGS84 UTM North Zone 10
    sr.centralMeridian = lon
    sr.latitudeOfOrigin = lat
    sr.falseEasting = 0
    sr.falseNorthing = 0
    sr.create()

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