zoukankan      html  css  js  c++  java
  • 【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个波段(分别对应RGB)的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获取。用于应付一般情况下的简单计算问题不大。

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

  • 相关阅读:
    Bootstrap 2.2.2 的新特性
    Apache POI 3.9 发布,性能显著提升
    SQL Relay 0.48 发布,数据库中继器
    ProjectForge 4.2.0 发布,项目管理系统
    红帽企业 Linux 发布 6.4 Beta 版本
    红薯 快速的 MySQL 本地和远程密码破解
    MariaDB 宣布成立基金会
    Percona XtraBackup 2.0.4 发布
    Rocks 6.1 发布,光盘机群解决方案
    精通Servlet研究,HttpServlet的实现追究
  • 原文地址:https://www.cnblogs.com/DannielZhang/p/5183761.html
Copyright © 2011-2022 走看看