Landsat8 L1 T数据是辐射校正数据使用地面控制点和数字高程模型数据进行精确校正后的数据产品,还需要做辐射校正(辐射定标和大气校正)。
一、python
1.辐射定标
辐射亮度L=DN*Gain+Bias
(1)代码
倾向于TIF格式的影像,所以output format选择的是“GTIFF”格式。
from osgeo import gdal
from osgeo import gdal_array
import numpy as np
from show import TwoPercentLinear
from matplotlib import pyplot as plt
import cv2 as cv
class Landsat8Reader(object):
def __init__(self):
self.base_path = r"D:\ProfessionalProfile\LandsatImage\LC08_L1TP_134036_20170808_20170813_01_T1\LC08_L1TP_134036_20170808_20170813_01_T1"
self.bands = 7
self.band_file_name = []
self.nan_position = []
def read(self):
for band in range(self.bands):
band_name = self.base_path + "_B" + str(band + 1) + ".tif"
self.band_file_name.append(band_name)
ds = gdal.Open(self.band_file_name[0])
image_dt = ds.GetRasterBand(1).DataType
image = np.zeros((ds.RasterYSize, ds.RasterXSize, self.bands),
dtype=np.float)
for band in range(self.bands):
ds = gdal.Open(self.band_file_name[band])
band_image = ds.GetRasterBand(1)
image[:, :, band] = band_image.ReadAsArray()
self.nan_position = np.where(image == 0)
image[self.nan_position] = np.nan
del ds
return image
def write(self, image, file_name, bands, format='GTIFF'):
ds = gdal.Open(self.band_file_name[0])
projection = ds.GetProjection()
geotransform = ds.GetGeoTransform()
x_size = ds.RasterXSize
y_size = ds.RasterYSize
del ds
band_cou