04-GDAL reads Sentinel 2 data

The reading of Sentinel2 data in GDAL is similar to the acquisition method of scientific data sets, as shown in the figure: For
Insert picture description here
example, the commonly used blue, green, red, and near-infrared commonly used bands are stored in the first data set list[0][0],list [0][1] is the description information.
Insert picture description here
An example of reading data in GDAL is as follows:


from osgeo import gdal
import numpy as np
import os
os.environ['CPL_ZIP_ENCODING'] = 'UTF-8'

filename = "G:\mypython3\gdal\data\S2A_MSIL1C_20170428T030541_N0205_R075_T49SER_20170428T031351.SAFE.zip"

root_ds = gdal.Open(filename)
ds_list = root_ds.GetSubDatasets()

sub = gdal.Open(ds_list[0][0])
sub_arr = sub.ReadAsArray()
dimen = np.array(sub_arr).shape
print(dimen)

print(f'打开数据为:{ds_list[0][1]}')
print(f'投影信息:{sub.GetProjection()}')
print(f'栅格波段数:{sub.RasterCount}')
print(f'栅格列数(宽度):{sub.RasterXSize}')
print(f'栅格行数(高度):{sub.RasterYSize}')

Guess you like

Origin blog.csdn.net/suntongxue100/article/details/114251342