Hi
I looked on the web for a way to calculate geometry ("shape.area@hectares!") with an easy way to choose between the data frame coordinate or data source coordiane to complete this thast with arcpy (python). Unfortunatly, I fourd something related to the use or the sursor (updateCursor).
is there an easy way to do so?
Thanks
Hi
It is for processing several feature calsses at a time. But the real reason is some time you want to process mutilple feature calsses that have different characteristics as projection. instead of reprojecting and calculating areas for example you have just to base your calculation on the data frame projection which is easier (time and memory reducing)
From a user's perspective, I can imagine that this can be easier.
There is a catch though. If the data has a different projection then the dataframe and no transformation is defined the on-the-fly projection might not be so accurate and will cause errors in the area calculation.
I did a little test:
Although the differences in area (ha) are small, they are all different. Maybe a tool that would project in memory to the output sr (using the transformation defined in the dataframe) and calculate the area and then link it back to the input featureclass would be an option...
Thanks
That is interesting and the option 2 will wor for me
I've not tested this code but are you talking about something like below?
mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] dfsr = df.spatialReference for row in arcpy.da.UpdateCursor(fc, ["SHAPE@XY","Xfield","Yfield"],"",dfsr): row[1],row[2] = row[0] updateRow(row)
Right click the field you want to calculate choose "Calculate Geometry" you'll find the choices your looking for there. The field must be Type "Double"
Thanks but I want to do exactly what you described in Python
Do you want to do it in python or do you want the tool that does it?
If you want to do it in python use the code above as a starting point pluck out some sample data and work through it.
If it's the tool follow the instructions above and you'll find it to be very easy.
You may also be interested in this tool ArcGIS Help (10.2, 10.2.1, and 10.2.2)