Calculate field @SQUAREMETERS

3005
6
07-08-2011 07:37 AM
RyanStephany
New Contributor
Could anyone tell me why calculating the shape.length@METERS works for me, but calculating shape.area@SQUAREMETERS does not.  Area always returns '0'.  I'm using 9.3, and the feature classes are in WGS 84.

Here are 2 examples:

~Length
gp.CalculateField_management(fc , field.name, '!SHAPE.LENGTH@METERS!', "PYTHON_9.3"

~Area
gp.CalculateField_management(fc , field.name, '!SHAPE.AREA@SQUAREMETERS!', "PYTHON_9.3"
Tags (2)
0 Kudos
6 Replies
DarrenWiens2
MVP Honored Contributor
SQUAREMETERS works for me the way you have it - but I'm using ArcGIS 10. Sorry to ask this, but you're not trying to calculate the area for a line feature class, are you?
0 Kudos
RyanStephany
New Contributor
don't be sorry, no I'm not calculating the area of a line,  I did find something though. 
It was returning '0' because I was only trying to keep 2 decimal places.  I am getting values, but they do not seem to be in meters squared.  When you tried it in 10 was the output of the calculation correct?

this is part of the actual code

my_fields = {'Polyline':{'LEN': '!SHAPE.LENGTH@METERS!'}, 'Polygon' : {'ARA': '!SHAPE.AREA@SQUAREMETERS!'}} 

gp.CalculateField_management(fc , field.name, '"%.2f" % float('+ self.my_fields[desc.ShapeType][field.name]+ ')', "PYTHON_9.3")
0 Kudos
RyanStephany
New Contributor
so the field I'm trying to calculate is populated with the same as the Shape_AREA field.
Shape_AREA =  0.000651
my_calculated_field = 0.000651
What_i_want = 6974972.61
0 Kudos
DanPatterson_Retired
MVP Emeritus
Did you try projecting the file first?
0 Kudos
RyanStephany
New Contributor
i tried reprojecting in the cursor, but got the same results.
0 Kudos
RyanStephany
New Contributor
What I don't understand is that converting !Shape.Length@METERS! works for polylines, but !Shape.Area@SQUAREMETERS! for polygons does not do any conversion.
0 Kudos