Select to view content in your preferred language

Shape_Area ?

3514
5
Jump to solution
04-22-2013 10:56 AM
BKS
by
Frequent Contributor
Question re: Shape_Area on Intersect output

While in ArcMap, if I direct the output of the Intersect tool to "in_memory", why is it that the "Shape_Area" and "Shape_Length" fields on the output layer table are both set to Null for all rows? 

If I do same on disk these fields are auto calculated.

Reason I ask is that I was automating this in python and made the assumption that "Shape_Area" would be updated based on Intersected polygon properties. 

Is this a bug or can someone set me straight (or provide best practices) on when to assume "Shape_Area" and "Shape_Length" fields are created/updated with respect to overlay tools?

Is there a simple and fast way to update these fields while in_memory?

Thanks so much, b
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
I could be wrong here, but I'm guessing these fields are intentionally not populated in the in_memory workspace to boost performance for in_memory feature classes.  Perhaps it makes the processing faster without the extra geometry stuff that would normally be tied to a FC in a gdb.  I'm just guessing here and that may be completely wrong.

I would suggest maybe using your scratch workspace for these temporary files as a best practice since you will need the area automatically updated.  I believe this is always automatically updated in file geodatabases.  At 10.1 you can actually set a scratch env workspace or you could set your normal workspace environment to your default geodatabase.  On my machine it would be like this:

arcpy.env.workspace = r'\\ccasr\users\gis\My Documents\ArcGIS\Default.gdb'

View solution in original post

0 Kudos
5 Replies
BKS
by
Frequent Contributor
Perhaps I can calculate the Shape_Area setting equal to Shape.Area. 

But would still like to know if this is a bug or can someone set me straight (or provide best practices) on when to assume "Shape_Area" and "Shape_Length" fields are created/updated with respect to overlay tools?

Thanks, b
0 Kudos
by Anonymous User
Not applicable
I could be wrong here, but I'm guessing these fields are intentionally not populated in the in_memory workspace to boost performance for in_memory feature classes.  Perhaps it makes the processing faster without the extra geometry stuff that would normally be tied to a FC in a gdb.  I'm just guessing here and that may be completely wrong.

I would suggest maybe using your scratch workspace for these temporary files as a best practice since you will need the area automatically updated.  I believe this is always automatically updated in file geodatabases.  At 10.1 you can actually set a scratch env workspace or you could set your normal workspace environment to your default geodatabase.  On my machine it would be like this:

arcpy.env.workspace = r'\\ccasr\users\gis\My Documents\ArcGIS\Default.gdb'
0 Kudos
by Anonymous User
Not applicable
Actually I just did a quick test in the interactive window.  I was using 10.1, but you can access the area token in an in_memory feature class like this:

'SHAPE@AREA'

I was able to access the area of an in_memory workspace feature class by using that same token:

>>> import arcpy
>>> ws = 'in_memory'
>>> cad = r'G:\Data\Geodatabase\Cedar_County.gdb\JURISDICTION\CORP_LIM'
>>> arcpy.CopyFeatures_management(cad, r'in_memory\corp')
<Result 'in_memory\\corp'>
>>> corp = r'in_memory\corp'
>>> with arcpy.da.SearchCursor(corp, ['SHAPE@AREA']) as rows:
 for row in rows:
  print row[0]

  
29602027.3534
5743768.43532
21250061.0234
1176983.15619
23122043.9827
29591444.8893
21709630.032
66368156.0184
56180139.9378
0 Kudos
ChrisSnyder
Honored Contributor
The Shape_Area and/or Shape_Length fields are not auto-populated when using the in_memory workspace. You have to populate then manually if you want to run a query against them, or you can of course use the row's shape object .area and/or .length properties in a cursor.

If you want to stay away from cursors, do something like this:

arcpy.CalculateField_management("in_memory\\test", "ACRES", "SHAPE.AREA@ACRES", "PYTHON")
0 Kudos
BKS
by
Frequent Contributor
Caleb and Chris,

Thanks for info.  This was helpful.

Forgot to update this earlier.

Cheers, b
0 Kudos