【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获取。用于应付一般情况下的简单计算问题不大。

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

时间: 2024-08-04 21:09:15

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

【GDAL】聊聊GDAL的数据模型

GDAL是个非常优秀的GIS数据操作库,最近在和实习生介绍GDAL的简单使用,顺手写下记录 本篇记录栅格数据,代码环境为C# 在GDAL中,栅格数据大致是以一个Dataset对应一个栅格数据文件(.Tif/GeoTiff格式),而这个栅格中的各种信息被包含在Dataset的对象中作为属性. 基本上一个栅格数据在GDAL的数据模型中存储是基于波段的方式,一般一个单波段数据在GDAL中读取后,所得到的Dataset中仅包含一个Band对象,而BandCount属性也为1.多波段数据类似,即是说在GD

【GDAL】GDAL栅格数据结构学习笔记(一): 关于Metadata

在维护一段代码时看到前任程序员写的获取栅格数据的CellSize的功能,竟然在知道GDAL的情况下去调用AE的接口来解算,觉得费解. 原来的思路是使用AE的Raster对象读取出Raster的文件大小和真实投影坐标对构造的矩形外框,再来算每个cell的长宽,觉得实在无语. 于是研究了下GDAL怎么获取到一些数据基本信息(Metadata)的. 搬运一下GDAL官方对其数据模型的Metadata的描述: GDAL metadata is auxiliary format and applicati

深入理解Spring AOP之二代理对象生成

深入理解Spring AOP之二代理对象生成 spring代理对象 上一篇博客中讲到了Spring的一些基本概念和初步讲了实现方法,当中提到了动态代理技术,包含JDK动态代理技术和Cglib动态代理 动态代理这部分我有过一篇博客介绍:动态代理,想深入了解的朋友能够看一看,再回想一下,Spring中怎样区分採用JDK动态代理和CGlib动态代理: 假设目标对象的实现类实现了接口.Spring AOP 将会採用 JDK 动态代理来生成 AOP 代理类: 假设目标对象的实现类没有实现接口,Spring

二、对象和类型(第四部分)

二.对象和类型(第四部分) 四.匿名类型 var关键字,它用于表示隐式类型化的变量.var与new关键字一起使用时,可以创建匿名类型.匿名类型只是继承自Object且没有名称的类.该类的定义从初始化器中推断,类似于隐式类型化的变量. 五.结构 结构是值类型,而不是引用类型.它们存储在栈中或存储为内联(inline)(如果它们是存储在堆中的另一个对象的一部分),其生存周期的限制与简单的数据类性一样. *.结构不支持继承. *.对于结构,构造函数的工作有一些区别.尤其是在编译器总是提供了一个无参数的

Hibernate复习(二)主要对象

1.SessionFactory 一个SessionFactory实例对应一个数据存储源,应用从SessionFactory中获得Session实例. SessionFactory有以下特点: –它是线程安全的,这意味着它的同一个实例可以被应用的多个线程共享. –它是重量级的,这意味着不能随意创建或销毁它的实例.如果应用只访问一个数据库,只需要创建一个SessionFactory实例,在应用初始化的时候创建该实 例.如果应用同时访问多个数据库,则需要为每个数据库创建一个单独的SessionFac

聊聊高并发(二十五)解析java.util.concurrent各个组件(七) 理解Semaphore

前几篇分析了一下AQS的原理和实现.这篇拿Semaphore信号量做样例看看AQS实际是怎样使用的. Semaphore表示了一种能够同一时候有多个线程进入临界区的同步器,它维护了一个状态表示可用的票据,仅仅有拿到了票据的线程尽能够进入临界区,否则就等待.直到获得释放出的票据. Semaphore经常使用在资源池中来管理资源.当状态仅仅有1个0两个值时,它退化成了一个相互排斥的同步器.类似锁. 以下来看看Semaphore的代码. 它维护了一个内部类Sync来继承AQS,定制tryXXX方法来使

聊聊高并发(二十九)解析java.util.concurrent各个组件(十一) 再看看ReentrantReadWriteLock可重入读-写锁

上一篇聊聊高并发(二十八)解析java.util.concurrent各个组件(十) 理解ReentrantReadWriteLock可重入读-写锁 讲了可重入读写锁的基本情况和主要的方法,显示了如何实现的锁降级.但是下面几个问题没说清楚,这篇补充一下 1. 释放锁时的优先级问题,是让写锁先获得还是先让读锁先获得 2. 是否允许读线程插队 3. 是否允许写线程插队,因为读写锁一般用在大量读,少量写的情况,如果写线程没有优先级,那么可能造成写线程的饥饿 关于释放锁后是让写锁先获得还是让读锁先获得,

Qt对象模型之二:对象树与元对象系统

一.对象树的概念 Qt中使用对象树(object tree)来组织和管理所有的QObject类及其子类的对象.当创建一个QObject时,如果使用了其他的对象作为其父对象(parent),那么这个 QObject就会被添加到父对象的children()列表中,这样当父对象被销毁时,这个QObject也会被销毁.实践表明,这个机制非常适合于管理GUI对象.例如,一个 QShortcut(键盘快捷键)对象是相应窗口的一个子对象,所以当用户关闭了这个窗口 时,这个快捷键也可以被销毁. QWidget作

ES6学习及总结(二):对象的解构

ES6学习及总结(二):对象的解构 一:数组的解构 1:ES6 允许按照一定模式,从数组和对象中提取值,对变量进行赋值,这被称为解构(Destructuring).本质上,这种写法属于“模式匹配”,只要等号两边的模式相同,左边的变量就会被赋予对应的值. let [foo, [[bar], baz]] = [1, [[2], 3]]; foo // 1 bar // 2 baz // 3 let [ , , third] = ["foo", "bar", "