Guest User

Untitled

a guest
Jan 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. inputLayer = arcpy.GetParameter(0)
  2. idField = arcpy.GetParameter(1)
  3. i = arcpy.GetParameter(2) # start value
  4. grid = r"R:GISPROJECTSDept_WaterUtilitiesToolsOceansideToolbarShapefilesGrids.shp"
  5. field_names = [f.name for f in arcpy.ListFields(grid)]
  6.  
  7. cursor = arcpy.UpdateCursor(inputLayer)
  8. arcpy.AddMessage("Generating ID's...n")
  9.  
  10. for row in cursor:
  11.  
  12. #Select by location
  13. arcpy.SelectLayerByLocation_management('grid', 'intersect', 'inputLayer')
  14.  
  15. for field in field_names:
  16. C = row.getValue("COL")
  17. R = row.getValue("ROW")
  18.  
  19. for id in idField
  20. ID =
  21.  
  22. Fc = str(i).zfill(2)
  23. Col = str(C).zfill(2)
  24. Row = str(R).zfill(2)
  25. Fno = str(i).zfill(3)
  26. Code = Fc + Col + Row + Fno
  27.  
  28. row.setValue(idField, Code)
  29. cursor.updateRow(row)
  30.  
  31. i += 1
  32.  
  33. arcpy.AddMessage("nnFinished...")
  34. arcpy.AddMessage("Last ID created: " + uniqueID)
Add Comment
Please, Sign In to add comment