Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import arcpy
  2.  
  3. def row_to_values(row):
  4. values = []
  5. for col in row:
  6. if isinstance(col, unicode) and col != u'f':
  7. # split and convert all entries to float
  8. values += (float(v) for v in col.split(','))
  9. else:
  10. values.append(col)
  11. return values
  12.  
  13.  
  14. with arcpy.da.SearchCursor(fc, fields) as cursor:
  15. for idx, row in enumerate(cursor):
  16. pt_annual_lists = []
  17. pt_loc = str(row[0]) + str(" ") + str(row[1])
  18. for y in xrange(1991,2016,1):
  19. pt_year_list = []
  20. result = arcpy.GetCellValue_management(in_raster = "D:/temp/ras" + str(y) + ".tiff", location_point = pt_loc, band_index="")
  21. cell_value = result.getOutput(0)
  22. pt_year_list.append(cell_value)
  23. cell_value = [s.replace('\n', ',') for s in pt_year_list]
  24. pt_annual_lists.append(row_to_values(cell_value))
  25.  
  26. # flatten list of lists
  27. pr_str = [val for sublist in pt_annual_lists for val in sublist]
  28. pr_flt = [float(i) for i in pr_str]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement