GEE中按淹没提取代码
时间: 2023-11-09 19:05:31 浏览: 111
在GEE中提取淹没信息可以采用以下代码:
1. 首先,需要导入GEE库:
```
var ee = require('users/earthengine/ee');
```
2. 然后,选择要分析的区域并加载DEM数据集:
```
//选择区域
var roi = ee.Geometry.Polygon(
[[[-121.895, 38.934], [-121.895, 38.883], [-121.805, 38.883], [-121.805, 38.934]]]);
//加载DEM数据集
var dem = ee.Image('USGS/SRTMGL1_003');
```
3. 接下来,计算该区域的最低点高程值:
```
// 计算最低点高程值
var elevation = dem.reduceRegion({
reducer: ee.Reducer.min(),
geometry: roi,
scale: 30,
maxPixels: 1e9
}).get('elevation');
```
4. 然后,根据最低点高程值计算淹没区域:
```
//计算淹没区域
var flood = dem.lte(elevation);
```
5. 最后,将淹没区域可视化:
```
//可视化
Map.addLayer(flood.updateMask(flood),
{palette: 'blue'}, 'Flooded');
```
完整代码如下:
```
var ee = require('users/earthengine/ee');
//选择区域
var roi = ee.Geometry.Polygon(
[[[-121.895, 38.934], [-121.895, 38.883], [-121.805, 38.883], [-121.805, 38.934]]]);
//加载DEM数据集
var dem = ee.Image('USGS/SRTMGL1_003');
// 计算最低点高程值
var elevation = dem.reduceRegion({
reducer: ee.Reducer.min(),
geometry: roi,
scale: 30,
maxPixels: 1e9
}).get('elevation');
//计算淹没区域
var flood = dem.lte(elevation);
//可视化
Map.addLayer(flood.updateMask(flood),
{palette: 'blue'}, 'Flooded');
```
阅读全文