Fast Polygons Insert

726
2
03-25-2014 12:49 AM
TaricMalk
New Contributor
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 🙂
Tags (2)
0 Kudos
2 Replies
JoshuaChisholm
Occasional Contributor III
None that I know of.

Also, nice script!
0 Kudos
ChrisSnyder
Regular Contributor III
If you aren't already, you may find much better performance in copying the oracle coordinate table locally, creating the polygon geom/feature class locally, and then appending the new features to your SDE-based featureclass  What you are doing seems legit, but reading/writing across the network can be quite slow. Usually I copy everything local first, create the product/data, and then post to the network.
0 Kudos