I have a list of lists that contains:

[vala, valb, valc, vald, (pntx, pnty)]
[vala, valb, valc, vald, (pntx, pnty)]
[vala, valb, valc, vald, (pntx, pnty)]

I also have a list of the field names that correspond to vala, valb, etc.

I am trying to use arcpy to create a feature class with all the information from the list, with the proper field names from the list of field names.

As I want the FC to be a point layer, I thought about using add XY event layer, however there seems to be no option for adding a field list and my x,y coordinates are in a tuple instead of individual list positions for indexing. I could probably create an empty feature class and use an insert cursor, but then how do I deal with the geometry?

I am using ArcMap 10.0.

  • Have you looked at the ESRI help section on writing geometries? resources.arcgis.com/en/help/main/10.1/index.html#//…
    – Aaron
    Jun 25, 2014 at 17:35
  • 1
    This Q/A works best if you post your attempted code in your question so we can see what you have tried.
    – artwork21
    Jun 25, 2014 at 17:52
  • Thanks. The code is pretty long and irrelevant to this problem that's why I don't want to post it. I read through the writing geometries stuff and I am now creating a feature class and will attempt to write the tuples to geometry objects. I was really looking for help on the basic algorithm.. I am creating a new feature class using a template with similar field names, then I will use an insert cursor and a for loop to populate the fields from my lists of lists. I think, this is quite new to me.
    – Dave
    Jun 25, 2014 at 18:09
  • It should always be possible, and preferred, to load a code snippet that works up to the point where you are stuck.
    – PolyGeo
    Jun 25, 2014 at 20:52
  • yes but that would not work in this situation as it was the algorithm that I was struggling with. I posted what my variables were and what I was trying to do with them. @radouxju was able to figure out exactly what I was asking...
    – Dave
    Jun 25, 2014 at 21:34

1 Answer 1


with 10.1, you'll need to use arcpy.da.insertcursor with the SHAPE@XY token

c = arcpy.da.InsertCursor(emptyshapefil, 
                          ("NAMEa", "NAMEb", "NAMEc", "NAMEd", "SHAPE@XY"))

for row in yourlist:

with 10.0 it is more complicated. you'll need arcpy.insertCursor and point geometry

c = arcpy.InsertCursor(emptyshapefile)

for row in yourlist:
    feat = c.newRow()   
    feat.NAMEa = row[0]
    feat.NAMEb = row[1]
    feat.NAMEc = row[2]
    feat.NAMEd = row[3]
    pnt = arcpy.Point()
    pnt.X = row[4][0]
    pnt.Y = row[4][1]
    feat.shape = pnt
del feat, c
  • Thanks, unfortunately I am using 10.0 so do not have access to the the arcpy.da module.
    – Dave
    Jun 25, 2014 at 19:53
  • Thanks a lot this worked perfectly! My field list is much longer than stated so I will try and write a for loop to assign the field names to the list positions but the basic idea is there, I really appreciate your help. Just one question though; what is the i=0 for?
    – Dave
    Jun 25, 2014 at 21:31
  • I have removed i=0. initially I wanted to use it for the FID, but in fact it is auto-incremented and I forgot to remove it.
    – radouxju
    Jun 26, 2014 at 6:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.