示例#1
0
 def read_tif(inputfile, band):
     tifObj = GeoTiffFile(inputfile)
     tifObj.readTif()
     data = tifObj.getBandData(band)
     width = tifObj.getWidth()
     height = tifObj.getHeight()
     proj = tifObj.getProj()
     geotrans = tifObj.getGeoTrans()
     return data, width, height, proj, geotrans
示例#2
0
def cal_radiance(warp_path, atmo_param, out_tif_path):
    radiance_factor = {'svi01': (0.013155036, -0.41), 'svi02': (0.0063949213, -0.24),
                       'svi03': (0.0013309018, -0.21), 'svi04': (5.52444e-05, -0.01)}

    # 先获取行列号
    tif_path = warp_path['svi01']
    tif_obj = GeoTiffFile(tif_path)
    tif_obj.readTif()
    width = tif_obj.getWidth()
    height = tif_obj.getHeight()
    proj = tif_obj.getProj()
    geo_trans = tif_obj.getGeoTrans()
    del tif_obj

    out_tif_obj = GeoTiffFile(out_tif_path)
    out_tif_data = np.zeros((4, height, width), dtype=np.float)
    i = 0
    for key in radiance_factor.keys():
        tif_path = warp_path[key]
        tif_obj = GeoTiffFile(tif_path)
        tif_obj.readTif()
        tif_data = tif_obj.getBandData(0)
        nan_loc = tif_data >= 65530
        # 辐射定标计算
        tif_data = tif_data * radiance_factor[key][0] + radiance_factor[key][1]
        # 大气校正计算
        # y=xa*(measured radiance)-xb;  acr=y/(1.+xc*y)
        y = atmo_param[key][0] * tif_data - atmo_param[key][1]
        ref_data = y / (1 + atmo_param[key][2] * y) * 1000
        # ref_data = ref_data.astype(np.uint16)
        ref_data[nan_loc] = 65533
        out_tif_data[i, :, :] = ref_data
        i += 1
    out_tif_obj.setDims(width, height, 4)
    out_tif_obj.setData(out_tif_data)
    out_tif_obj.setProj(proj)
    out_tif_obj.setGeoTrans(geo_trans)
    out_tif_obj.writeTif()

    print("finish")