【问题标题】:Change number of bands in rasterio更改光栅中的波段数
【发布时间】:2023-02-10 20:43:39
【问题描述】:

我正在处理一些 TIFF 图像,我想向现有图像添加另一个波段。

这是我用来读取图像的代码:

# Read the image
image = rasterio.open('input.tiff')

with rasterio.open("input.tiff", 'r+') as src:
   crs = rasterio.crs.CRS({"init": "epsg:4326"})
   src.crs = crs

使用此代码,我可以更改 CRS:这是图像的元数据:

{'driver': 'GTiff',
 'dtype': 'uint8',
 'nodata': None,
 'width': 524,
 'height': 499,
 'count': 3,
 'crs': CRS.from_epsg(4326),
 'transform': Affine(1.0, 0.0, 0.0,
        0.0, 1.0, 0.0)}

我想改变数数值从 3 到 4。

我在用着光栅.

提前致谢。

【问题讨论】:

    标签: python-3.x rasterio satellite-image sentinel2


    【解决方案1】:

    您可以使用.profile 读取元数据,然后更新它。

    with rasterio.open('input.tiff') as r:
          profile = r.profile
    
    profile.update(count = 4)
    profile.update(crs = 'EPSG:32643')
    

    【讨论】:

      猜你喜欢
      • 2011-08-01
      • 2015-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 2013-03-16
      • 2014-05-08
      • 1970-01-01
      相关资源
      最近更新 更多