0

I'm trying to do a coordinate transformation for points with ArcPy in ArcGIS Pro by using x and y coordinates as Input.

I tried the following:

import arcpy 
inputSRS = arcpy.SpatialReference(31467) 
outputSRS = arcpy.SpatialReference(25832)
gt = 'DHDN_To_ETRS_1989_3'
pt = arcpy.Point() 
pt.X = 3453122.083947168 
pt.Y = 5427803.663703325 
print "Input XY: {} {}".format(pt.X, pt.Y)
ptgeo = arcpy.PointGeometry(pt, inputSRS)
ptgeo1 = ptgeo.projectAs(outputSRS, gt)
pt1 = ptgeo1.lastPoint
print "Output XY: {} {}".format(pt1.X, pt1.Y)

I get a SyntaxError.

3

Syntax error is not an arcpy error, it is a pure python error. ArcGIS Pro uses Python 3, and you need to add parentheses around the print function.

import arcpy 
inputSRS = arcpy.SpatialReference(31467) 
outputSRS = arcpy.SpatialReference(25832)
gt = 'DHDN_To_ETRS_1989_3'
pt = arcpy.Point() 
pt.X = 3453122.083947168 
pt.Y = 5427803.663703325 
print ("Input XY: {0} {1}".format(pt.X, pt.Y))
ptgeo = arcpy.PointGeometry(pt, inputSRS)
ptgeo1 = ptgeo.projectAs(outputSRS, gt)
pt1 = ptgeo1.lastPoint
print ("Output XY: {0} {1}".format(pt1.X, pt1.Y))

Here is the output:

Input XY: 3453122.083947168 5427803.663703325
Output XY: 453065.4793016275 5426072.203723424

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.