In an attempt to create a python add-in for ArcMap that will pass x and y coordinates to another application via a mouse click on the map, I have written the following code. I need the output coordinates to be in WGS_1984 and therefore have to project a geometry object. The problem I'm running into is that whenever the script executes the projectAs() method I get the following error. Code at bottom
import arcpyimport pythonaddinsimport webbrowserimport os, sysfrom arcpy import envarcpy.env.overwriteOutput = Trueclass ToolClass2(object): """Implementation for StreetView_addin.tool (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks. def onMouseDownMap(self, x, y, button, shift): mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] sr_df = df.spatialReference xValue = x yValue = y pointList = [[xValue, yValue]] point = arcpy.Point() for pt in pointList: point.X = pt[0] point.Y = pt[1] pointGeometry = arcpy.PointGeometry(point, sr_df) pointGeometry.projectAs("WGS 1984") centroid = str(pointGeometry.centroid) centList = centroid.split(" ") xValue2 = centList[0] yValue2 = centList[1]I have tried adding the optional transformation for the projectAs() method as well without success. What am I missing here?
أكثر...

import arcpyimport pythonaddinsimport webbrowserimport os, sysfrom arcpy import envarcpy.env.overwriteOutput = Trueclass ToolClass2(object): """Implementation for StreetView_addin.tool (Tool)""" def __init__(self): self.enabled = True self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks. def onMouseDownMap(self, x, y, button, shift): mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] sr_df = df.spatialReference xValue = x yValue = y pointList = [[xValue, yValue]] point = arcpy.Point() for pt in pointList: point.X = pt[0] point.Y = pt[1] pointGeometry = arcpy.PointGeometry(point, sr_df) pointGeometry.projectAs("WGS 1984") centroid = str(pointGeometry.centroid) centList = centroid.split(" ") xValue2 = centList[0] yValue2 = centList[1]I have tried adding the optional transformation for the projectAs() method as well without success. What am I missing here?
أكثر...