Hello,
I'm trying to find the area of various polygons in a shapefile using a script cursor. I assume I use "SHAPE@AREA" according to this: Reading geometries—ArcPy Get Started | ArcGIS Desktop
However, I also want to specify the units (acres). Right now, I get a lot of numbers that don't seem to make much sense. It looks like I need the getArea method to specify the units: Polygon—ArcPy classes | ArcGIS Desktop
Basically, I'm wondering, how does the getArea method work? Are there examples of the syntax?
Many thanks!
If the numbers are small based on what you expect, I think you are most likely working with data that are in decimal degrees. Your life would be a lot simpler if your script simply called
Add Geometry Attributes—Data Management toolbox | ArcGIS Desktop
and returned the area units in what you want, accounting for the projection that your data need to be in. If you try to do this through an update or other cursor, you will have to account for the projection as well as the unit change.
If you just need the information to be temporary, you can always add
Delete Field—Data Management toolbox | ArcGIS Desktop
to your workflow to remove the previously added field.
In short, it will cut down on potential errors. (both tools exist in arcmap and ArcGIS pro)
Thank you Dan! Is there anyway I can add the areas to a new field? I would like to customize the field name and populate it with the areas.
The aforementioned tool produces a new field which you can provide a name for and get the units your want if you specify the parameters you need
Calculate Field—Data Management toolbox | ArcGIS Desktop can take care of this for you, e.g..: !shape.area@ACRES!
Python expressions can use the geometry area and length properties with an areal or linear unit to convert the value to a different unit of measure (for example, !shape.length@kilometers!). If the data is stored in a geographic coordinate system and a linear unit is supplied (for example, miles), the length will be calculated using a geodesic algorithm. Using areal units on geographic data will yield questionable results as decimal degrees are not consistent across the globe.