当前位置: 首页 > news >正文

GEE统计特定区域特定时间上的Landsat/Sentinel的影像信息

GEE统计特定区域特定时间上的Landsat/Sentinel的影像信息

  • 前言
  • 统计Landsat影像的信息
  • 统计Sentinel影像的信息

前言

很多时候,我们会想查看一个特定的研究区和研究时间范围内的Landsat 或者 Sentinel系列数据集中影像的一些参数信息,如成像时间,云量,数量等等,以帮助我们确定应该如何筛选影像。比如,我想知道1990年至2020年期间,所有覆盖到北京市的Landsat影像的信息,如下图所示。Landsat系列和Sentinel系列是目前使用最为广泛的两个影像数据集,现在,我提供了实现这一操作的代码框架,大家可以在此基础上进行修改,以得到你想要提取的信息。基于此框架,你还可以扩展到其他影像数据集(如MODIS等)。

在这里插入图片描述

统计Landsat影像的信息

统计Landsat系列信息的代码如下:

import ee
import geemap
import pandas as pd
geemap.set_proxy(port=7778)
geemap.ee_initialize()
Map = geemap.Map()# 加载研究区
json_path = './北京市.geojson'
study_region = geemap.geojson_to_ee(json_path)
bound = study_region.bounds()
start_year = 1990
end_year = 2020
start_month = 4
end_month = 10# 创建Landsat影像集合,过滤日期和区域
landsat5 = ee.ImageCollection("LANDSAT/LT05/C02/T1_L2")
landsat7 = ee.ImageCollection("LANDSAT/LE07/C02/T1_L2")
landsat8 = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
landsat9 = ee.ImageCollection("LANDSAT/LC09/C02/T1_L2")landsat_collection1 = ee.ImageCollection.merge(landsat5, landsat7)
landsat_collection2 = ee.ImageCollection.merge(landsat8, landsat9)
landsat_collection = ee.ImageCollection.merge(landsat_collection1, landsat_collection2) \.filterBounds(study_region) \.filter(ee.Filter.calendarRange(start_year, end_year, 'year')) \.filter(ee.Filter.calendarRange(start_month, end_month, 'month'))# 云量和质量等级函数
# 云量小于20%-1级,20%到40%-2级,40%-60%-3级, 60%-80%-4级,大于80%-5级
def assign_quality(cloud_coverage):if 0 <= cloud_coverage < 20:return 1elif 20 <= cloud_coverage < 40:return 2elif 40 <= cloud_coverage < 60:return 3elif 60 <= cloud_coverage < 80:return 4elif 80 <= cloud_coverage <= 100:return 5else:return None  # 提取影像的日期和传感器信息
def extract_info(image):date = image.date().format('YYYY-MM-dd')satellite = image.get('SPACECRAFT_ID')sensor = image.get('SENSOR_ID')year = image.date().get('year')month = image.date().get('month')day = image.date().get('day')cloud_coverage = image.get('CLOUD_COVER')quality = ee.Algorithms.If(ee.Number(cloud_coverage).lt(20), 1,ee.Algorithms.If(ee.Number(cloud_coverage).lt(40), 2,ee.Algorithms.If(ee.Number(cloud_coverage).lt(60), 3,ee.Algorithms.If(ee.Number(cloud_coverage).lt(80), 4, 5))))imgID = image.id()return ee.Feature(None, {'成像日期': date,'卫星型号': satellite,'传感器名称': sensor,'影像年份': year,'影像月份': month,'当月日': day,'云量': cloud_coverage,'质量': quality,'GEEID': imgID})# 应用函数并创建特征集合
image_data = landsat_collection.map(extract_info)
feature_collection = ee.FeatureCollection(image_data)# 获取数据并转换为DataFrame
data = feature_collection.getInfo()
features = data['features']
records = []for feature in features:records.append(feature['properties'])# 创建DataFrame
df = pd.DataFrame(records)# 导出为Excel文件
df.to_excel('./landsat_statistic.xlsx', index=False)

在这段代码中,我统计1990年-2020年北京市生长季(4-10月)的Landsat影像的信息,最总结果输出为’landsat_statistic.xlsx’的excel表格。

统计Sentinel影像的信息

统计Sentinel影像信息的代码与统计Landsat影像的代码思路是一致的,以下是详细代码:

import ee
import geemap
import pandas as pd
geemap.set_proxy(port=7778)
geemap.ee_initialize()
Map = geemap.Map()# 加载研究区
json_path = './北京市.geojson'
study_region = geemap.geojson_to_ee(json_path)
bound = study_region.bounds()
start_year = 1990
end_year = 2020
start_month = 4
end_month = 10# 创建Sentinel-2影像合集
s2Collection = (ee.ImageCollection("COPERNICUS/S2_SR_HARMONIZED").filterBounds(study_region).filter(ee.Filter.calendarRange(start_year, end_year, 'year')).filter(ee.Filter.calendarRange(start_month, end_month, 'month')))# 云量和质量等级函数
def assign_quality(cloud_coverage):if 0 <= cloud_coverage < 20:return 1elif 20 <= cloud_coverage < 40:return 2elif 40 <= cloud_coverage < 60:return 3elif 60 <= cloud_coverage < 80:return 4elif 80 <= cloud_coverage <= 100:return 5else:return None  # 提取影像的日期和传感器信息
def extract_info(image):img_id = image.get('system:id')date = image.date().format('YYYY-MM-dd')year = image.date().get('year')month = image.date().get('month')day = image.date().get('day')doy = ee.Date(image.get('system:time_start')).getRelative('day','year').add(1)cloud_coverage = image.get('CLOUDY_PIXEL_PERCENTAGE')quality = ee.Algorithms.If(ee.Number(cloud_coverage).lt(20), 1,ee.Algorithms.If(ee.Number(cloud_coverage).lt(40), 2,ee.Algorithms.If(ee.Number(cloud_coverage).lt(60), 3,ee.Algorithms.If(ee.Number(cloud_coverage).lt(80), 4, 5))))return ee.Feature(None, {'ID': img_id,'成像日期': date,'影像年份': year,'影像月份': month,'当月日': day,'云量': cloud_coverage,'质量': quality,'doy': doy})# 应用函数并创建特征集合
image_data = s2Collection.map(extract_info)
feature_collection = ee.FeatureCollection(image_data)# 获取数据并转换为DataFrame
data = feature_collection.getInfo()
features = data['features']
records = []for feature in features:records.append(feature['properties'])# 创建DataFrame
df = pd.DataFrame(records)# 导出为Excel文件
df.to_excel('./S2影像信息统计.xlsx', index=False)

这段代码同样统计了1990至2020年北京市生长季的Sentinel2的影像信息

http://www.dtcms.com/a/561545.html

相关文章:

  • 徐州建设企业网站苏州网站优化排名推广
  • 百度提交网站的入口地址网络地区广告代理
  • 全面认识 InnoDB:从架构到 Buffer Pool 深入解析
  • TREE SEARCH FOR LLM AGENT REINFORCEMENTLEARNING
  • 网站建设分金手指排名二八铜川矿业公司网站
  • 阿里云网站建设需要多少钱cms在线
  • 把AI“编”进草垫:1KB决策树让宠物垫自己报「如厕记录」
  • 没有网站如何做SEO推广有用吗wordpress 代码优化
  • IDEA如何进行远程Debug
  • 巧用AI解决日常开发中遇到的问题!
  • 东台建设企业网站网站集约化建设进度汇报
  • 车载 Serdes:TI、Rohm 拥抱 HSMT
  • 网站制作推荐21ic项目外包平台
  • 建设行业年度峰会网站微信小程序开发教程官方文档
  • 全国首家“数字资源集团”,落地重庆
  • 网站建设学的是什么知识开设公司网站
  • Vue2学习笔记(二)
  • 基于STM32设计的淡水湖水产养殖系统_319
  • 兼容Win11,DPS 9.01 免注册版下载安装教程
  • 台州网站建设公司特色的岑溪网站开发
  • 自己网站服务器徐州人才网招聘信息
  • Week 23: 深度学习补遗:Transformer整体构建
  • Qwen2.5-Omni、TMRoPE-Time Aligned Rotary Positional Embedding 概念
  • 从一到无穷大 #54 数据管理中宽表(Wide Table)的问题阐述与解决方案
  • springboot系统设计选题3
  • 文学类网站怎么做淮南人才网
  • 【机器学习12】无监督学习:K-均值聚类与异常检测
  • zero的大型网站seo教程岳阳网站建设哪家好
  • 手机网站制作电话计算机网络中小型企业网络设计方案
  • 做的最好的门户网站做视频用的网站有哪些