tmw2

Fast Polygons Insert

Discussion created by tmw2 on Mar 25, 2014
Latest reply on Mar 25, 2014 by csny490
Hi :)

I'm currently trying to insert polygons into a feature class given a list of (ID, X coordinate, Y coordinate) from Oracle

So far I do:

pntsLayer = arcpy.InsertCursor(myTableLnk)

def save(cursor, list, seq):
 if seq is None or len(list) == 0:
  return
 pfeat = cursor.newRow()
 array = arcpy.Array(list)
 poly = arcpy.Polygon(array, oracle_sr)
 pfeat.SHAPE = poly
 pfeat.POLY_ID = seq
 cursor.insertRow(pfeat)

list = []
prev_seq = None

for (seq, long, lat) in data:
 pnt = arcpy.Point() # moved out before the loop?
 pnt.X = long
 pnt.Y = lat
 if prev_seq != seq:
  save(pntsLayer , list, prev_seq)
  prev_seq = seq
  list = []
 list.append(pnt)



Do I have a way to insert them faster without looping on the data? (using some kind of array / arcpy function / csv file insert)

thanks :)

Outcomes