GEE学习——初学者如何下载指定区域的Sentinel-2影像

简介

初学者如何下载指定区域的Sentinel-2影像?

初学者可以按照以下步骤利用Google Earth Engine(GEE)下载指定区域的Sentinel-2影像:

  1. 登录GEE账号并打开代码编辑器。代码编辑器位于GEE主页左上角的"Code Editor"按钮。

  2. 在代码编辑器中,点击左上角的"Apps Script"按钮,打开一个新的脚本。

  3. 在脚本中,首先导入Sentinel-2影像的库:

var sentinel2 = ee.ImageCollection("COPERNICUS/S2");

  1. 确定你感兴趣的区域,并用一个几何图形表示。例如,你可以创建一个矩形:
var areaOfInterest = ee.Geometry.Rectangle(xMin, yMin, xMax, yMax);

其中xMin,yMin,xMax,yMax是你定义的感兴趣区域的最小经度、最小纬度、最大经度和最大纬度。

  1. 使用filterBounds()函数筛选位于感兴趣区域内的Sentinel-2影像:
var filteredCollection = sentinel2.filterBounds(areaOfInterest);

  1. 使用filterDate()函数选择特定的时间范围内的影像,如果你有时间限制的话:
var startDate = ee.Date('2022-01-01');
var endDate = ee.Date('2022-12-31');
var filteredCollection = filteredCollection.filterDate(startDate, endDate);

  1. 如果你只需要最新的一张影像,你可以使用sort()函数按时间排序并取最后一张:
var sortedCollection = filteredCollection.sort('system:time_start', false);
var latestImage = sortedCollection.first();

  1. 如果你需要下载整个影像集,你可以使用getDownloadURL()函数获取下载链接:
var downloadURL = latestImage.getDownloadURL({
  scale: 10,  // 分辨率
  crs: 'EPSG:4326',  // 投影坐标系
  region: areaOfInterest.geometry().bounds(),  // 下载区域
});
  1. 点击代码编辑器右上角的"Run"按钮运行脚本。这将在控制台输出下载链接。

  2. 复制下载链接并在浏览器中打开,然后选择保存影像。

以上是一个简单的示例,初学者可以根据自己的需求和兴趣对代码进行修改和扩展。

函数

clip(geometry)

Clips an image to a Geometry or Feature.

The output bands correspond exactly to the input bands, except data not covered by the geometry is masked. The output image retains the metadata of the input image.

Use clipToCollection to clip an image to a FeatureCollection.

Returns the clipped image.

根据几何图形或特征剪切图像。

输出波段与输入波段完全对应,但几何图形未覆盖的数据会被屏蔽。输出图像保留输入图像的元数据。

使用 clipToCollection 将图像剪辑到特征集合。

返回剪切后的图像。

Arguments:

this:image (Image):

The Image instance.

geometry (Feature|Geometry|Object):

The Geometry or Feature to clip to.

Returns: Image

原始代码

// 定義時間範圍和地理範圍
var startDate = '2004-01-26';
var endDate = '2024-01-25';
var geometry = ee.Geometry.Rectangle([120, 20, 122, 26]);

// 加載 Sentinel-2 表面反射率影像集合
var s2SrCollection = ee.ImageCollection("COPERNICUS/S2_SR")
  .filterDate(startDate, endDate)
  .filterBounds(geometry);

// 定義 NDWI 函數
function addNDWI(image) {
  var ndwi = image.no
  • 26
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值