9

I'm dealing with a varierty of spatial polygon files (shapefiles, file/personal gdb feature classes, sde feature classes (some with spatial views)) and depending on the file type, I get a mulittude of Shape Area feature class field names (the required field, not a created one)

So for example, the field names vary from "Shape_Area", "SHAPE_Area", "SHAPE.AREA", "GEOMETRY_Area", "GEOMETRY.AREA"

I'm writing a python script to pull out the area of all these types of feature classes and I do something along the lines of:

for field in arcpy.ListFields(fc):
    if field.name in ["Shape_Area", "SHAPE_Area", "SHAPE.AREA", "GEOMETRY_Area", "GEOMETRY.AREA"]:
         do something

I'm wondering if there's a more clever way of pulling out the shape area field, instead of just listing out all the ways it can be named? There doesn't seem to be a field property for something like Area. is there any other way of doing this?

12

What about the following:

fc = "path to input feature class"
desc = arcpy.Describe(fc)
areafieldname = desc.areaFieldName

Should work on various feature classes that have auto generated Area fields. This will exclude shapefiles.

  • Thanks Barbarossa. I must have missed that property in Describe because I was looking for ways to describe the fields and that one didn't come up in my search. That works perfectly. – Mike Mar 20 '14 at 19:40

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.