AnsweredAssumed Answered

Insert Cursor placing points from dictionary on top of each other

Question asked by joerob1515 on Jan 10, 2018
Latest reply on Jan 10, 2018 by joerob1515

I am trying to push xy locations that are being pulled from a dictionary into an insert cursor.  The cursor is reading the xy locations correctly but is putting them all in the same location instead of placing them in the actual location when pulled into a map.

 

What I have tried:

1. changing the SHAPE@XY - all still come in the same location on top of each other

2. removing out of try statement - all still come in the same location on top of each other

3. removing edit session - returns error saying that I have to use one

 

I have attached a test GDB that includes the test data. To run code, all you have to do is change the location to where ever you save the GDB.  If you have any solution, PLEASE RESPOND

 

Here is the my code:

import arcpy

#Trigger: When it sees a change in date, it will then add frequency to that date
#What needs to be populated: compound, maintenance task, and park

#Attributes for Each Maintenance Task feature
CompAttribs = {
#Compound Name : [Location of Point, Compound, Park]
"Mississippi Shelter": [(751925.962298,279303.484179) ,"Mississippi Shelter", "Walter Chandler"],
"Willow Road": [(815946.106614, 815946.106614), "Willow Road", "Hickory Hill Park"],
"MLK Riverside": [(747845.301725, 301161.452951),"MLK Riverside", "King"],
"City Center Armory":[(771656.687393, 309099.380722),"City Center Armory", "Glenview"],
"Armory":[(791820.996015, 313373.492286),"Armory","Galloway"],
"Kennedy":[(800029.764326, 336054.100493),"Kennedy","Kennedy"],
"Frayser":[(769122.906674, 359343.580918),"Frayser","Firestone"]

}

 

MaintFreq = {
"Empty Trash Receptacle": ["Maint",2],
"Inventory Report": ["Maint",30],
"Leaf Mulching": ["Maint",14,],
"Litter Pick Up":["Maint",2],
"Mow Edge Trim Blow": ["Maint",1],
#"Preventative Maint on Equipment": 1,
"Pruning Hedges": ["Maint",14],
"Safety Assessment": ["MaintOps",30],
"Asset Inspection": ["MaintOps",30],
"Playground Inspection": ["MaintOps",30]

}

 

 

arcpy.env.workspace =r"C:\\Users\\josephr.roberts\\Documents\\ArcGIS\\JR_Working\\TestDatabase_1.gdb"
workspace = r"C:\\Users\\josephr.roberts\\Documents\\ArcGIS\\JR_Working\\TestDatabase_1.gdb"

fc = r"C:\\Users\\josephr.roberts\\Documents\\ArcGIS\\JR_Working\\TestDatabase_1.gdb\\MaintenanceRequest_1"
Fields = ["SHAPE@XY","Compound_Name","Maintenance_Task","Maintenance_Task_MandO"]

 


#Opening Editing Session
print "Editing Session Opened"
edit = arcpy.da.Editor(workspace)
edit.startEditing(True, False)
edit.startOperation()

 

try:
   newMaintTask = arcpy.da.InsertCursor(fc,Fields)
   for Comps in CompAttribs:
      for Task in MaintFreq:
         if MaintFreq[Task][0] == "Maint":
            newMaintTask.insertRow([CompAttribs[Comps][0],CompAttribs[Comps][1],Task,""])
         else:
            newMaintTask.insertRow([CompAttribs[Comps][0],CompAttribs[Comps][1],"",Task])

 


del newMaintTask

print "point added"

 

except Exception, e:
   print "Unexpected error:", sys.exc_info()[0]
   raise

edit.stopOperation()
edit.stopEditing(True)

 

Attachments

Outcomes