-
Notifications
You must be signed in to change notification settings - Fork 0
/
landtemperature.py
57 lines (46 loc) · 1.45 KB
/
landtemperature.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# -*- coding: UTF-8 -*-
import os
import arcpy
from arcpy.sa import *
import random
arcpy.env.Overwrite = True
arcpy.env.scratchWorkspace = os.path.dirname(__file__)
RESULT_FOLDER = 'D:\\surface'
TARGET_FOLDER = r'F:\\landsat 2020'
def land_surface_temp(file, i):
path_thermal = file + "\\" + file[-40:] + "_B10.tif"
RADIANCE_MULT_BAND = 0.0003342
RADIANCE_ADD = 0.1
Oi = 0.29
thermal_band = Raster(path_thermal)
print thermal_band
print "band condirmed"
Rfloat = Float(thermal_band)
top_temperature = Rfloat * RADIANCE_MULT_BAND + RADIANCE_ADD - Oi
temp_tif = "temp{}.tif".format(i)
top_temperature.save(temp_tif)
top_temperature = Raster(temp_tif)
top_temperature = Float(top_temperature)
K1_CONSTANT_BAND_10 = 774.8853
K2_CONSTANT_BAND_10 = 1321.0789
divide1 = Divide(K1_CONSTANT_BAND_10 , (top_temperature + 1))
ln1 = Ln(divide1)
surface_temp = Divide(K2_CONSTANT_BAND_10, ln1) - 273.15
location = file[-30:-24]
date = file[-24:-15]
name = date + "_" + location
print name
path = "surface_temp" + name + ".tif"
print path
surface_temp.save(path)
i += 1
if __name__ == '__main__':
print("GO")
arcpy.env.Overwrite = True
i = 1
for x in os.listdir(TARGET_FOLDER):
file_path = os.path.join(TARGET_FOLDER, x)
if os.path.isdir(file_path):
print(file_path)
land_surface_temp(file_path, i)
i += 1