统计研究区内Landsat和Sentinel影像逐年逐月数量
统计研究区内Landsat影像数量
2021-08-28 17:11:39 星期六
导出结果为数量csv文件
var ROI = ee.FeatureCollection("users/xxx/xxx");
function cloudmask(image) {
// Remove edge pixels that don't occur in all bands
var mask1 = image.mask().select('B.*').reduce(ee.Reducer.min());
return image.updateMask(mask1);
}
function setImageInfo(image){
var date = image.get("SENSING_TIME");//获取影像时间
var year=ee.Date(date).get("year");
image=image.set("year",year);//设置属性 年
var month=ee.Date(date).get("month");
image=image.set("month",month);//设置属性 月
var day=ee.Date(date).get("day");
image=image.set("day",day);//设置属性 日
return image;
}
///////////////////////////////////////////////////////
//------------------Landsat5--------------------------//
var colTM2 = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR")
.filterDate('1989-01-01', '2012-05-31')
.filterBounds(ROI)
.map(cloudmask)
.map(setImageInfo);
print(colTM2)
//export imageCollection information
Export.table.toDrive({
collection:colTM2,
description:"L5_Stat",
fileNamePrefix:"L5_Stat",
fileFormat:"CSV",
selectors:["year","month","day","WRS_PATH","WRS_ROW"]});
////////////////////////////////////////////////////////
//------------------Landsat7--------------------------//
var colETM = ee.ImageCollection("LANDSAT/LE07/C01/T1_SR")
.filterDate('1999-01-01', '2003-05-31')
.filterBounds(ROI)
.map(cloudmask)
.map(setImageInfo);
//export imageCollection information
Export.table.toDrive({
collection:colETM,
description:"L7_Stat",
fileNamePrefix:"L7_Stat",
fileFormat:"CSV",
selectors:["year","month","day","WRS_PATH","WRS_ROW"]});
///////////////////////////////////////////////////////
//------------------Landsat8--------------------------//
var colOLI = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
.filterDate('2013-01-01', '2019-12-31')
.filterBounds(ROI)
.map(cloudmask)
.map(setImageInfo);
//export imageCollection information
Export.table.toDrive({
collection:colOLI,
description:"L8_Stat",
fileNamePrefix:"L8_Stat",
fileFormat:"CSV",
selectors:["year","month","day","WRS_PATH","WRS_ROW"]});
function maskS2clouds(image) {
var qa = image.select('QA60');
// Bits 10 and 11 are clouds and cirrus, respectively.
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
function setImageInfo(image){
var date = image.get("system:time_start");//获取影像时间
var year=ee.Date(date).get("year");
image=image.set("year",year);//设置属性 年
var month=ee.Date(date).get("month");
image=image.set("month",month);//设置属性 月
var day=ee.Date(date).get("day");
image=image.set("day",day);//设置属性 日
return image;
}
var S2 = ee.ImageCollection('COPERNICUS/S2_HARMONIZED')
.filterDate('2015-04-01', '2022-04-01')
// Pre-filter to get less cloudy granules.
.filterBounds(roi)
//.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20))
//.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',40))
//.filter(ee.Filter.gte('CLOUDY_PIXEL_PERCENTAGE',20))
//.filter(ee.Filter.gte('CLOUDY_PIXEL_PERCENTAGE',80))
.map(setImageInfo);
//print(S2)
//export imageCollection information
Export.table.toDrive({
collection:S2,
description:"S2dt_Stat",
fileNamePrefix:"S2dt_Stat",
fileFormat:"CSV",
selectors:["year","month","day","CLOUDY_PIXEL_PERCENTAGE"]});
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD');
// Filter Sentinel-1 collection for study area, date ranges and polarization components
var sCollection = sentinel1
//filter by aoi and time
.filterDate('2015-04-01', '2022-04-01')
// Pre-filter to get less cloudy granules.
.filterBounds(roi)
// Filter to get images with VV and VH dual polarization
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
// Filter to get images collected in interferometric wide swath mode.
.filter(ee.Filter.eq('instrumentMode', 'IW')).map(setImageInfo);
// Also filter based on the orbit: descending or ascending mode
var desc = sCollection.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'));
var asc = sCollection.filter(ee.Filter.eq('orbitProperties_pass', 'ASCENDING'));
// Inspect number of tiles returned after the search; we will use the one with more tiles
print("descending tiles ",desc.size());
print("ascending tiles ",asc.size());
// Also Inspect one file
print(asc);
Export.table.toDrive({
collection:sCollection,
description:"S1dt_Stat",
fileNamePrefix:"S1dt_Stat",
fileFormat:"CSV",
selectors:["year","month","day","resolution_meters"]});
//在python中基于年和月统计影像数量 云量
import pandas as pd
df=pd.read_csv(r"C:\Users\dyw\Downloads\S2dt_Stat.csv")
num_20=df.loc[df['CLOUDY_PIXEL_PERCENTAGE']<20].groupby(['year']).count()
num_40=df.loc[(df['CLOUDY_PIXEL_PERCENTAGE'] >= 20) & (df['CLOUDY_PIXEL_PERCENTAGE'] < 40)].groupby(['year']).count()
num_60=df.loc[(df['CLOUDY_PIXEL_PERCENTAGE'] >= 40) & (df['CLOUDY_PIXEL_PERCENTAGE'] < 60)].groupby(['year']).count()
num_80=df.loc[(df['CLOUDY_PIXEL_PERCENTAGE'] >= 60) & (df['CLOUDY_PIXEL_PERCENTAGE'] < 80)].groupby(['year']).count()
num_100=df.loc[(df['CLOUDY_PIXEL_PERCENTAGE'] >= 80)].groupby(['year']).count()
month_20=df.loc[df['CLOUDY_PIXEL_PERCENTAGE']<20].groupby(['month']).count()
S1df=pd.read_csv(r"C:\Users\dyw\Downloads\S1dt_Stat.csv")
num_s1=S1df.groupby(['year']).count()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示