Select to view content in your preferred language

Trouble using "in_memory" to temporarily store geomety

2585
11
Jump to solution
04-14-2014 07:02 AM
JamesMcBroom1
New Contributor
Here's my script that I'm writing before I convert it into an Add-in button. It seems like it's actually creating a feature class called "in_memory" in my default.gdb...

layers = get_layers() bigArea = 0 bigAreaPIN = None with arcpy.da.SearchCursor(layers['parcels_fc'], ["Shape_Area", "PIN10"]) as rows:     for row in rows:         if row[0] > bigArea:             bigArea = row[0]             bigAreaPIN = row[1]         else: pass  del rows  print bigArea, bigAreaPIN  arcpy.Dissolve_management(layers['parcels_fc'], "in_memory")  with arcpy.da.SearchCursor("in_memory", ["SHAPE@"]) as rows:     for row in rows:         newPolygon = row[0] del rows  subparcels = []  with arcpy.da.UpdateCursor(layers['parcels_fc'], ["PIN10", "SHAPE@"]) as rows:     for row in rows:         if row[0] == bigAreaPIN:             row[1] = newPolygon             rows.updateRow(row)         else:             subparcels.append(row[0])             rows.deleteRow() del rows  with arcpy.da.InsertCursor(layers['superparcel'], ["original", "superparcel"]) as insert:     for x in subparcels:         insert.insertRow((x,bigAreaPIN)) del insert  arcpy.RefreshActiveView() arcpy.Delete_management("in_memory")


Any idea what I'm doing wrong here?
Tags (2)
0 Kudos
11 Replies
JamesMcBroom1
New Contributor
OK - it's finally working.

I added the clearInMemory function as suggested by jamesfreddyc and then put everything into the add-in and began debugging thatway. arcpy.env.overwriteOutput = True works correctly when using the add-in, not with copy-and-pasting into the Python window.

Thanks all for your help.
0 Kudos
JamesCrandall
MVP Frequent Contributor
arcpy.env.overwriteOutput = True works correctly when using the add-in, not with copy-and-pasting into the Python window.

Thanks all for your help.


Did you set the workspace prior to setting overwriteOutput property?

In any case, I just prefer to do the removal myself rather than using the overwriteOutput = True because I am certain the job is getting done.
0 Kudos