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")
Solved! Go to Solution.
arcpy.env.overwriteOutput = True
arcpy.Dissolve_management(layers['parcels_fc'], r"in_memory\working") arcpy.da.SearchCursor(r"in_memory\working", ["SHAPE@"])
arcpy.env.overwriteOutput = True
Changed my code to include the double slash and I'm still getting an error about in_memory/dissolved existing when I run the script for a second time.
def clearINMEM(): """ clear out the IN_MEMORY workspace of any featureclasses """ arcpy.env.workspace = "IN_MEMORY" fcs = arcpy.ListFeatureClasses() ### for each FeatClass in the list of fcs's, delete it. for f in fcs: arcpy.Delete_management(f)