Guest User

Untitled

a guest
Dec 12th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import arcpy
  2. island_list =['island 1','island 2']#change to your list of islands
  3.  
  4. def letter_code(x):
  5. if ord(x)>89:
  6. return chr(65)
  7. else:
  8. return chr(ord(x)+1)
  9. done = 'yes'
  10. x='ZZ'
  11. for isl in island_list:
  12. if done=='yes':
  13. qry = "island = '"+isl+"'" #change "island" to your field name
  14.  
  15. arcpy.SelectLayerByAttribute_management("your_shp","NEW_SELECTION",qry)**#change your_shp to your shape file name**
  16. cur = arcpy.UpdateCursor("your_shp")#change your_shp to your shapefile name
  17. done='no'
  18.  
  19. for row in cur:
  20. if x[1]=='Z':
  21. x=letter_code(x[0])+letter_code(x[1])
  22. else:
  23. x=x[0]+letter_code(x[1])
  24. print x
  25.  
  26. row.code=x#letter_code(chr(x+i))+letter_code(chr(x+i+1))#change "row.code" to row.your field name where you want your letter combinations
  27. cur.updateRow(row)
  28.  
  29. done = 'yes'
Add Comment
Please, Sign In to add comment