AI Earth代码运行后,影像无法显示在地图上,怎么回事?导出影像是有的,打印影像信息也有就是不显示import aie
import calendar
aie.Authenticate()
aie.Initialize()
shp = aie.FeatureCollection('user/f01c82488e9f83d4684c88f44f260a2e')
start_year = 2020
end_year = 2020
start_month = 7
end_month = 9
k = 5
map = aie.Map(
    center=shp.getCenter(),
    height=800,
    zoom=5
)
bands = ['SR_B1', 'SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6','SR_B7', 'ST_B10']
vis_params = {
    'bands': ['SR_B4', 'SR_B3', 'SR_B2'],
    'min': 0.0,
    'max': 0.3,
}
def removeLandsatCloud(image):
    cloudShadowBitMask = (1 << 4)
    cloudsBitMask = (1 << 3)
    qa = image.select('QA_PIXEL')
    mask = qa.bitwiseAnd(aie.Image(cloudShadowBitMask)).eq(aie.Image(0)) \
                    .And(qa.bitwiseAnd(aie.Image(cloudsBitMask)).eq(aie.Image(0)))
    return image.updateMask(mask)
def applyScaleFactors(image):
    opticalBands = image.select('SR_B.').multiply(aie.Image(0.0000275)).add(aie.Image(-0.2))
    thermalBands = image.select('ST_B.*').multiply(aie.Image(0.00341802)).add(aie.Image(149.0)).add(aie.Image(-273.5))
    return image.addBands(opticalBands, None, True).addBands(thermalBands, None, True)
def filterByMonth(dataset, shp, year, month):
    _, max_day = calendar.monthrange(year, month)
    start_date = f'{year:04d}-{month:02d}-01'
    end_date = f'{year:04d}-{month:02d}-{max_day:02d}'
filtered = dataset.filterDate(start_date, end_date) \
                  .filterBounds(shp) \
                  .map(removeLandsatCloud).map(applyScaleFactors)
return filtered
def filterByMonthsRange(dataset, shp, year, start_month, end_month):
    all_filtered_datasets = []
    combined_dataset = aie.ImageCollection([])
for month in range(start_month, end_month + 1):
    monthly_filtered = filterByMonth(dataset, shp, year, month)
    all_filtered_datasets.append(monthly_filtered)
    # 逐月合并数据集
    combined_dataset = combined_dataset.merge(monthly_filtered)
return combined_dataset
for year in range(start_year, end_year + 1, k):
    combined_dataset = aie.ImageCollection([])
# 根据年份选择数据集类型
dataset = aie.ImageCollection('LANDSAT_LC08_C02_T1_L2')
# 筛选特定月份的数据
combined_dataset = filterByMonthsRange(dataset, shp, year, start_month, end_month)
    # 打印数据集大小
print(f'Size of combined dataset for year {year}:', combined_dataset.size().getInfo())
# 计算中值影像
yearly_median_image = combined_dataset.select(bands).median().clipToCollection(shp)
print(f'Year: {year}')
print("Band count:", len(yearly_median_image.bandNames().getInfo()))
print("Band names:", yearly_median_image.bandNames().getInfo())
 # 如果中值影像有数据,继续可视化
if yearly_median_image:
    # 数据可视化
    map.addLayer(
        yearly_median_image,
        vis_params,
        f'Filled True Color {year}',
        bounds=yearly_median_image.getBounds()
    )
else:
    print(f'No image data for year {year}')
map
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。