I've attached a zip file (Toolbox.zip) that should contain a 10.2.x toolbox (Toolbox.tbx) with a contained model (ingeniously named 'Model') - this model contains a Calculate Value tool with the corrected snippet...see further notes below.- !shape.area@squarekilometers! is for the field calculator or the Calculate Field tool...- For use with your tool, Calculate Value, the 'SHAPE@' token was used to return geometry with the da search cursor; area in your desired units was returned via the arcpy 'getArea' method. The code block:
def getArea(features):
areaTotal = sum([row[0].getArea('PLANAR', 'SQUAREKILOMETERS') for row in arcpy.da.SearchCursor(features, ['SHAPE@'])])
return "%s %s" % (areaTotal, 'Square Kilometers')
- ...and the 'expression' calling the 'getArea' function (notice the proper use of inline variable substitution, where 'myFeatures' is a model parameter [feature layer type] by that name):
getArea("%myFeatures%")
Wayne