Guest User

Untitled

a guest
Jan 23rd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. def circle1():
  2. path = Path(path_top)
  3.  
  4. ye = path_refer[:4]
  5. mo = path_refer[4:6]
  6. da = path_refer[6:8]
  7.  
  8. if ye.startswith("*") and ye != "***":
  9. ye = "*"
  10. mo = path_refer[1:3]
  11. da = path_refer[3:5]
  12. elif mo.startswith("*") and mo != "**":
  13. mo = "*"
  14. da = path_refer[5:7]
  15. elif path_refer == "***":
  16. ye = "*"
  17. mo = "*"
  18. da = "*"
  19.  
  20. arr = numpy.zeros((rows, columns), dtype=np_band_type)
  21.  
  22. for s in path.glob('{}/{}/{}'.format(ye, mo, da)):
  23. if os.path.isdir(s):
  24. listdir = os.listdir(s)
  25. os.chdir(os.path.join(path_top, s))
  26.  
  27. for a_img in listdir:
  28. if a_img.startswith(refer[:5]) and int(a_img[5:9]) >= year_beg and int(a_img[5:9]) <= year_end:
  29. for b_img in listdir:
  30. if b_img.startswith(refer[:5]) and int(b_img[9:11]) >= month_beg and int(b_img[9:11]) <= month_end:
  31. for c_img in listdir:
  32. if c_img.startswith(refer[:5]) and int(c_img[11:13]) >= day_beg and int(c_img[11:13]) <= day_end:
  33. for d_img in listdir:
  34. if d_img.startswith(refer[:5]) and int(d_img[-8:-6]) >= hour_beg and int(d_img[-8:-6]) <= hour_end:
  35. ds = gdal.Open(str(d_img), gdal.GA_ReadOnly)
  36.  
  37. band = ds.GetRasterBand(b_num_wor)
  38. b_arr = band.ReadAsArray(0, 0, columns, rows).astype(np_band_type)
  39. for r in range(rows):
  40. for c in range(columns):
  41. if param_type == "lt":
  42. if param_x < b_arr[r,c]:
  43. arr[r,c] += 1
  44. elif param_type == "let":
  45. if param_x > b_arr[r,c]:
  46. arr[r,c] += 1
  47. elif param_type == "dr":
  48. if param_x < b_arr[r,c] < param_y:
  49. arr[r,c] += 1
  50.  
  51. return arr
  52.  
  53. measure_source = gdal.Open(MyReferenceFile)
  54. v_band = measure_source.GetRasterBand(b_num_wor)
  55. gdal_band_type = v_band.DataType
  56. np_band_type = gdal_array.GDALTypeCodeToNumericTypeCode(gdal_band_type)
  57.  
  58. line 175, in circle1
  59. band = ds.GetRasterBand(b_num_wor)
  60. AttributeError: 'NoneType' object has no attribute 'GetRasterBand'
Add Comment
Please, Sign In to add comment