Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 9 down vote accepted

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.

share|improve this answer
    
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 at 19:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.