I'm trying to get a numerical value for the area of a polygon that I am generating from an extent object. In this case, I am using the "onRectangle" function in the python addins for arcpy. The problem starts when using the getArea method on the polygon geometry. I have no intention of writing this polygon to disk. Ultimately, I want to be able to compare the extent of a user drawn rectangle to the dataframe extent. Here's what I've got so far.
def onRectangle(self, rectangle_geometry): frameExtent = rectangle_geometry XMAX = frameExtent.XMax XMIN = frameExtent.XMin YMAX = frameExtent.YMax YMIN = frameExtent.YMin pnt1 = arcpy.Point(XMIN, YMIN) pnt2 = arcpy.Point(XMIN, YMAX) pnt3 = arcpy.Point(XMAX, YMAX) pnt4 = arcpy.Point(XMAX, YMIN) print XMAX, XMIN, YMAX, YMIN array = arcpy.Array() array.add(pnt1) array.add(pnt2) array.add(pnt3) array.add(pnt4) array.add(pnt1) rectPoly = arcpy.Polygon(array) global rectArea rectArea = rectPoly.getArea() print str(rectArea) return rectArea
The python window in ArcMap returns this error:
TypeError: Invalid geometry type for method. Any pointers would be appreciated for both getting the area of the polygon and comparing it (percentage wise) to the full data extent would be appreciated.
I'm using ArcGIS 10.2 advanced license.