#这就是我在我感兴趣的区域“roi”上创建集合的方式:
def maskS2clouds(image):
qa = image.select('QA60');
cloudBitMask = 1 << 10;
cirrusBitMask = 1 << 11;
mask = qa.bitwiseAnd(cloudBitMask).eq(0).And(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
#计算 NDVI
def addNDVI(image):
ndvi = image.normalizedDifference(['B8', 'B4']).rename('ndvi')
return image.addBands([ndvi])
dataset = ee.ImageCollection('COPERNICUS/S2').filterDate(first_date, end_date).filterBounds(roi).filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', cloud_percentage))\
.map(addNDVI)\
.map(maskS2clouds)\
.sort('system:time_start')
print("number of images:", dataset.size().getInfo())
#现在我有一个来自我导入的 .csv 文件(称为“points_Ferndale.csv”)的点列表:
points=pd.read_csv('/content/gdrive/My Drive/colab_input/points_Ferndale.csv')
#from 'points',我现在以这种方式提取了经纬度信息:
points2=points_coordinates.iloc[1:,:]; points3 = points2.to_numpy();
#如果我打印points3,我得到: [[-3.36411764 51.67790352] [-3.3395374 51.63922807] [-3.38080455 51.62893532] [-3.46511922 51.6209735]-3.46511922 51.6209736]-3.659573751.62077361.6207736.16.16.16.16.16.16.16.16.16.16.16.16.16.16.16.16.16.16.16.46.16.16.16.46.16.16.16.16.16.76.16.46.1659736
#问题是我现在不知道如何从我的图像集合中映射 ndvi 的值 #over 每个 #point in points3?
#我想我需要做一些类似的事情:
points4 = [ee.Feature(ee.Geometry.Point(points3))]