Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Trouble using "in_memory" to temporarily store geomety

$
0
0
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...

Code:

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?

Viewing all articles
Browse latest Browse all 2485

Trending Articles