Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy
- def row_to_values(row):
- values = []
- for col in row:
- if isinstance(col, unicode) and col != u'f':
- # split and convert all entries to float
- values += (float(v) for v in col.split(','))
- else:
- values.append(col)
- return values
- with arcpy.da.SearchCursor(fc, fields) as cursor:
- for idx, row in enumerate(cursor):
- pt_annual_lists = []
- pt_loc = str(row[0]) + str(" ") + str(row[1])
- for y in xrange(1991,2016,1):
- pt_year_list = []
- result = arcpy.GetCellValue_management(in_raster = "D:/temp/ras" + str(y) + ".tiff", location_point = pt_loc, band_index="")
- cell_value = result.getOutput(0)
- pt_year_list.append(cell_value)
- cell_value = [s.replace('\n', ',') for s in pt_year_list]
- pt_annual_lists.append(row_to_values(cell_value))
- # flatten list of lists
- pr_str = [val for sublist in pt_annual_lists for val in sublist]
- pr_flt = [float(i) for i in pr_str]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement