【GDAL】聊聊GDAL的数据模型(二)——Band对象

在GDAL中栅格数据直接参与各种计算的重要对象是Band

摘录官方描述:

Raster Band

A raster band is represented in GDAL with the GDALRasterBand class. It represents a single raster band/channel/layer. It does not necessarily represent a whole image. For instance, a 24bit RGB image would normally be represented as a dataset with three bands, one for red, one for green and one for blue.

Gdal 中数据以Dataset为基础,具体的栅格数据值被存储在这个Dataset的Band对象之中,一个Dataset可以存储多个Band对象。例如RGB色彩模型的图象,在GDAL的数据模型中被认为是一个拥有3个波段(分别对应R\G\B)的Dataset。

 

A raster band has the following properties:

  • A width and height in pixels and lines. This is the same as that defined for the dataset, if this is a full resolution band.

     该值在C#中通过Band.XSize, Band.YSize获取

  • A datatype (GDALDataType). One of Byte, UInt16, Int16, UInt32, Int32, Float32, Float64, and the complex types CInt16, CInt32, CFloat32, and CFloat64.

     

  • A block size. This is a preferred (efficient) access chunk size. For tiled images this will be one tile. For scanline oriented images this will normally be one scanline.

     

  • A list of name/value pair metadata in the same format as the dataset, but of information that is potentially specific to this band.

     实际上是以String[]方式存储的(这是C/C++程序员的习惯做法),猜测该matadata即是Dataset中获取的metadata内容一致,且不全面。

  • An optional description string.

     

  • An optional single nodata pixel value (see also NODATA_VALUES metadata on the dataset for multi-band style nodata values).

    在C#中Nodata是对band而言的,理论上如果一个Dataset包含多个Band对象,这些Band对象的Nodata值是不能保证一致的。所以需要分别获取。另外需要注意的一点是,在创建要写入数据的Dataset时,为其Band指定Nodata需要考虑这个数据本身的有效值范围和DataType,设置合适的值。 

 

  • An optional nodata mask band marking pixels as nodata or in some cases transparency as discussed in RFC 15: Band Masks.

     

  • An optional list of category names (effectively class names in a thematic image).

     

  • An optional minimum and maximum value.

     该值用于获取Band中数据的最大最小统计值,不过测试了下偶尔会出现统计值不正确的情况,建议自己写方法来处理。

  • An optional offset and scale for transforming raster values into meaning full values (i.e. translate height to meters).

     

  • An optional raster unit name. For instance, this might indicate linear units for elevation data.

     

  • A color interpretation for the band. This is one of:

    • GCI_Undefined: the default, nothing is known.
    • GCI_GrayIndex: this is an independent gray-scale image
    • GCI_PaletteIndex: this raster acts as an index into a color table
    • GCI_RedBand: this raster is the red portion of an RGB or RGBA image
    • GCI_GreenBand: this raster is the green portion of an RGB or RGBA image
    • GCI_BlueBand: this raster is the blue portion of an RGB or RGBA image
    • GCI_AlphaBand: this raster is the alpha portion of an RGBA image
    • GCI_HueBand: this raster is the hue of an HLS image
    • GCI_SaturationBand: this raster is the saturation of an HLS image
    • GCI_LightnessBand: this raster is the hue of an HLS image
    • GCI_CyanBand: this band is the cyan portion of a CMY or CMYK image
    • GCI_MagentaBand: this band is the magenta portion of a CMY or CMYK image
    • GCI_YellowBand: this band is the yellow portion of a CMY or CMYK image
    • GCI_BlackBand: this band is the black portion of a CMYK image.

     

  • A color table, described in more detail later.

     

  • Knowledge of reduced resolution overviews (pyramids) if available.

其实在真正使用中,比较重要的无非是数据的nodata、xSize、ySize等等,投影等信息由Dataset获取。用于应付一般情况下的简单计算问题不大。

下一篇将详细解释一个常规的数据读取和处理的流程。

转载于:https://www.cnblogs.com/DannielZhang/p/5183761.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值