GADL根据历史DEM数据弥补现在DEM栅格数据的缺失

如果你有历史DEM数据和现有的DEM数据,并且想要使用GADL(Geospatial Data Abstraction Library)来根据历史DEM数据来弥补现在DEM栅格数据的缺失,可以考虑以下步骤:

1. 确保已安装GADL库,并加载所需的DEM数据。

2. 首先,将历史DEM数据和现有DEM数据打开为GDAL数据集。
import gdal

# 打开历史DEM数据
historical_dem = gdal.Open("historical_dem.tif")
# 打开现有DEM数据
current_dem = gdal.Open("current_dem.tif")
```

3. 获取历史DEM和现有DEM的坐标系、仿射变换信息等。

```python
historical_projection = historical_dem.GetProjection()
current_projection = current_dem.GetProjection()

historical_geotransform = historical_dem.GetGeoTransform()
current_geotransform = current_dem.GetGeoTransform()

# 确定新DEM的行列数(根据需要进行调整)
rows, cols = current_dem.RasterYSize, current_dem.RasterXSize
```

4. 创建一个输出数据集来存储修复后的DEM数据。

```python
driver = gdal.GetDriverByName('GTiff')

# 创建输出DEM数据集
output_dem = driver.Create("output_dem.tif", cols, rows, 1, gdal.GDT_Float32)
output_dem.SetProjection(current_projection)
output_dem.SetGeoTransform(current_geotransform)

output_band = output_dem.GetRasterBand(1)
```

5. 遍历每个像素点,判断当前DEM是否为缺失值(例如0或任意无效值),如果是,则使用历史DEM数据进行填充。

```python
import numpy as np

for y in range(rows):
    for x in range(cols):
        current_elevation = current_band.ReadAsArray(x, y, 1, 1)
        
        # 判断当前DEM是否为缺失值
        if current_elevation == 0 or np.isnan(current_elevation):
            historical_elevation = historical_band.ReadAsArray(x, y, 1, 1)
            
            # 使用历史DEM数据填充

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

认真学GIS

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

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

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

打赏作者

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

抵扣说明:

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

余额充值