ArcEngine和GDAL读写栅格数据机制对比(一)
最近应用AE开发插值和栅格转等值线的程序,涉及到栅格读写的有关内容。联想到ArcGIS利用了GDAL的某些东西,从AE的OMD中也发现RasterDataset和RasterBand这些命名和GDAL的很相似。所以觉得应该对比学习一下:ArcEngine和GDAL读写栅格数据机制对比。
AE涉及栅格图像读写的主要是Workspace、RasterDataset、Pixel blocks和 RasterBand。如图所示。RasterDataset实现了接口IrasterBandCollection,是RasterBand的集合。所以RasterDataset依赖于RasterBand。
1) RasterDataset:
The RasterDataset class represents a raster dataset stored in a storage media, file system, geodatabase, or in memory. RasterDataset is a file raster dataset if it is opened from a file system or a personal geodatabase, and it is a database raster dataset if it is opened from a file geodatabase or an ArcSDE geodatabase. A raster dataset in an unmanaged raster catalog, where raster datasets are stored in a file system, is also a file raster dataset. ArcGIS allows you to create an in-memory RasterDataset where the pixels are stored in memory. This type of raster dataset has the characteristics of a file raster dataset. A file raster dataset and a geodatabase raster dataset behave the same except for some minor differences.
Creating raster datasets in various workspaces requires specifying the properties of the raster data to be created as well as the properties of the storage container. In an ArcSDE geodatabase, raster data is stored as a set of database management system (DBMS) tables that are used to manage the pixel values, pyramids, and other auxiliary information. The pixels of raster data are divided into small tiles, and each tile is stored as a binary large object (BLOB) in a row of the block table. The raster column in the business table defines the properties of the raster dataset, and the geometry column defines properties of the footprint of the raster dataset. A file geodatabase raster has a similar implementation as an ArcSDE geodatabase. The only difference is that raster data is stored as a set of file geodatabase tables in the file system instead of in a relational geodatabase.
IRasterWorkspaceEx is used to create a raster dataset and a raster catalog in a geodatabase. When creating data in a geodatabase, RasterDef can be used to set the properties of the raster field, and RasterStorageDef can be used to specify the storage properties such as tile size, cell size, pyramid origin, and compression. Because raster data in a personal geodatabase is implemented by converting it to an IMAGINE file format and managing it in the personal geodatabase, only some of the raster storage properties apply to a personal geodatabase (such as cell size and compression).
Creating a geodatabase raster dataset using IRasterWorkspaceEx initially creates an empty raster dataset, which servers as a placeholder for the specified properties of the raster dataset. The extent and pixel values of the dataset can be populated by mosaicking from other raster dataset or, alternatively, writing using PixelBlock.
To create a raster dataset in any supported file raster format using IRasterWorkspace2, the origin, number of bands, pixel type, width, and height of the raster dataset must be specified along with other required parameters. The created raster dataset has a specified dimension and a default pixel value. The default pixel value is normally the maximum value of the specified pixel type and can be populated by writing pixel blocks. If IRasterWorkspace2 is used to create a geodatabase raster dataset, the default storage parameters are used.
2) Raster
The Raster class, in contrast to the static RasterDataset and RasterBand classes, is transient in nature and can be modified without affecting the source data. This allows the raster to represent what you want—for example, you can set a transformation or a pixel filter on a raster, specify a projection or extent, and set other properties without changing the raster dataset. If you want to persist change, the modified raster can be saved to another raster dataset using the ISaveAs interface.
Although Raster is always transient in nature, it must be associated with one or more raster bands, which provides a source for the data to be read through the raster. As such, the Raster is most easily understood as a vehicle to provide resampling, transformation, and data type conversion from one or more raster bands to a desired output coordinate system.
3) RasterBand
A representation of a single band of a raster dataset on disk.
RasterBand is a non-creatable object. References to non-creatable objects must be obtained through other objects.
The RasterBand object represents an existing band of a raster dataset. This band may be the only band in a single raster dataset or one band in a multiband raster dataset.
A RasterBand can be obtained from a RasterDataset or a Raster using IRasterBandCollection::Item.
The RasterBand class represents an existing band of a raster dataset. You can access a RasterBand of a Raster or a RasterDataset. Regardless of whether it is derived from the static RasterDataset or the transient Raster, the RasterBand always represents a static band of raster data.
The IRasterBand interface provides access to the raster color map, histogram, statistics, and attribute table if they exist.
4) Pixel blocks
The PixelBlock class is a container for pixel arrays. It has the properties of width, height, pixel type, and number of planes. Each plane is a pixel array corresponding to one raster band. The PixelBlock class can handle generic pixel arrays from any raster data source. To support different pixel types, PixelBlock transports pixels in a SafeArray, which can contain many different data types.
The PixelBlock class is used to read, modify, and write pixel values or a portion of pixel values of the raster data. Create a pixel block from a raster using the IRaster.CreatePixelBlock method. This initializes the size and other properties of the pixel block. Use the IRaster.Read method to read the pixel values into the pixel block, then use IPixelBlock3.PixelData or PixelDataByRef to get or modify the pixel values of the pixel block. The IRasterEdit interface can be used to write the pixel block to the raster dataset.
GDAL涉及栅格图像读写的主要是GDALDataset和GDALRasterBand。
GDALDataset:A set of associated raster bands, usually from one file.
GDALRasterBand:A single raster band (or channel)
理解AE和GDAL的类似要从PixelBlock和RasterIO函数说起。RasterIO的参数说明可以参阅李民录的CADN博客。
| CPLErr GDALDataset::RasterIO | ( | GDALRWFlag | eRWFlag, | |
| int | nXOff, | |||
| int | nYOff, | |||
| int | nXSize, | |||
| int | nYSize, | |||
| void * | pData, | |||
| int | nBufXSize, | |||
| int | nBufYSize, | |||
| GDALDataType | eBufType, | |||
| int | nBandCount, | |||
| int * | panBandMap, | |||
| int | nPixelSpace, | |||
| int | nLineSpace, | |||
| int | nBandSpace | |||
| ) |
| eRWFlag | Either GF_Read to read a region of data, or GF_Write to write a region of data. | |
| nXOff | The pixel offset to the top left corner of the region of the band to be accessed. This would be zero to start from the left side. | |
| nYOff | The line offset to the top left corner of the region of the band to be accessed. This would be zero to start from the top. | |
| nXSize | The width of the region of the band to be accessed in pixels. | |
| nYSize | The height of the region of the band to be accessed in lines. | |
| pData | The buffer into which the data should be read, or from which it should be written. This buffer must contain at least nBufXSize * nBufYSize * nBandCount words of type eBufType. It is organized in left to right,top to bottom pixel order. Spacing is controlled by the nPixelSpace, and nLineSpace parameters. | |
| nBufXSize | the width of the buffer image into which the desired region is to be read, or from which it is to be written. | |
| nBufYSize | the height of the buffer image into which the desired region is to be read, or from which it is to be written. | |
| eBufType | the type of the pixel values in the pData data buffer. The pixel values will automatically be translated to/from the GDALRasterBand data type as needed. | |
| nBandCount | the number of bands being read or written. | |
| panBandMap | the list of nBandCount band numbers being read/written. Note band numbers are 1 based. This may be NULL to select the first nBandCount bands. | |
| nPixelSpace | The byte offset from the start of one pixel value in pData to the start of the next pixel value within a scanline. If defaulted (0) the size of the datatype eBufType is used. | |
| nLineSpace | The byte offset from the start of one scanline in pData to the start of the next. If defaulted (0) the size of the datatype eBufType * nBufXSize is used. | |
| nBandSpace | the byte offset from the start of one bands data to the start of the next. If defaulted (0) the value will be nLineSpace * nBufYSize implying band sequential organization of the data buffer. |
PixelBlock的作用是不是和RasterIO函数中的pData、nXSize和nYSize很像?
Raster主要是将数据存储在内存中,用于显示,连接起显示和数据源。
ArcEngine和GDAL读写栅格数据机制对比(一)的更多相关文章
- ArcEngine和GDAL读写栅格数据机制对比(二)—— IPixelBlock读写栅格
以下是设定一个矩形框,用IPixelBlock将256*256瓦片tile拼接成一个整块影像的代码,row1, col1, row2, col2是一个矩形框行列号范围.level是瓦片的金字塔等级.这 ...
- Apache与Nginx对客户端请求的处理机制对比
Apache与Nginx对客户端请求的处理机制对比 模块 大致为四个模块,核心模块.HTTP模块.邮件模块,以及第三方模块 核心模块主要包含两类功能的支持,一类是主体功能,包括进程管理,权限管理,错误 ...
- 浅谈linux读写同步机制RCU
RCU是linux系统的一种读写同步机制,说到底他也是一种内核同步的手段,本问就RCU概率和实现机制,给出笔者的理解. [RCU概率] 我们先看下内核文档中对RCU的定义: RCU is a sync ...
- [评测]低配环境下,PostgresQL和Mysql读写性能简单对比(欢迎大家提出Mysql优化意见)
[评测]低配环境下,PostgresQL和Mysql读写性能简单对比 原文链接:https://www.cnblogs.com/blog5277/p/10658426.html 原文作者:博客园--曲 ...
- 基于Keepalived高可用集群的MariaDB读写分离机制实现
一 MariaDB读写分离机制 在实现读写分离机制之前先理解一下三种主从复制方式:1.异步复制:MariaDB默认的复制即是异步的,主库在执行完客户端提交的事务后会立即将结果返给给客户端,并不关心从库 ...
- gdal读写图像分块处理
转自赵文原文 gdal读写图像分块处理(精华版) Review: 用gdal,感觉还不如直接用C++底层函数对遥感数据进行处理.因为gdal进行太多封装,如果你仅仅只是Geotif等格式进行处理,IO ...
- 关于GDAL读写Shp乱码的问题总结
目录 1. 正文 1.1. shp文件本身的编码的问题 1.2. 设置读取的编码方式 1.2.1. GDAL设置 1.2.2. 解码方式 1.2.3. 其他 2. 参考 1. 正文 最近在使用GDAL ...
- 顺序、随机IO和Java多种读写文件性能对比
概述 对于磁盘的读写分为两种模式,顺序IO和随机IO. 随机IO存在一个寻址的过程,所以效率比较低.而顺序IO,相当于有一个物理索引,在读取的时候不需要寻找地址,效率很高. 基本流程 总体结构 我们编 ...
- iOS运行时编程(Runtime Programming)和Java的反射机制对比
运行时进行编程,类似Java的反射.运行时编程和Java反射的对比如下: 1.相同点 都可以实现的功能:获取类信息.属性设置获取.类的动态加载(NSClassFromString(@“clas ...
随机推荐
- Unity资源解决方案之AssetBundle
1.什么是AssetBundle AssetBundle是Unity pro提供的一种用来存储资源的文件格式,它可以存储任意一种Unity引擎能够识别的资源,如Scene.Mesh.Material. ...
- Spring Framework 官方文档学习(四)之Validation、Data Binding、Type Conversion(一)
题外话:本篇是对之前那篇的重排版.并拆分成两篇,免得没了看的兴趣. 前言 在Spring Framework官方文档中,这三者是放到一起讲的,但没有解释为什么放到一起.大概是默认了读者都是有相关经验的 ...
- iis部署网站,使用虚拟路劲
此前一直使用vs2010,没有考虑过配置IIS,但是一个项目完成后交付给甲方使用.肯定是要考虑IIS的安装和部署的.现从IIS的安装和asp.NET项目的部署两个方面讲解. IIS安装: 网上很多教程 ...
- iOS 注冊本地通知(推送)
注:按Home键让App进入后台执行时.方可查看通知. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithO ...
- js中解析json时候的eval和$.parseJSON()的区别以及JSON.stringify()
1.第一个区别是:安全性 json格式非常受欢迎,而解析json的方式通常用JSON.parse()但是eval()方法也可以解析,这两者之间有什么区别呢? JSON.parse()之可以解 ...
- 真 · windows环境下php7.0以上开启curl方法
看这个说明之前,大家肯定百度在网上看到什么: 配置php.ini ,把curl_dll前的分号去掉 在php.ini中,查找extension=php_curl.dll ,找到后把它前面的分号去掉 之 ...
- poj_1084 剪枝-IDA*
题目大意 给出一个由2*S*(S+1)构成的S*S大小的火柴格.火柴可以构成1x1,2x2...SxS大小的方格.其中已经拿走了几个火柴,问最少再拿走几个火柴可以使得这些火柴无法构成任何一个方格. 题 ...
- Android 7.1 SystemUI--Multi-Window多窗口模式
PhoneStatusBar.java private View.OnLongClickListener mRecentsLongClickListener = new View.OnLongClic ...
- java - OutOfMemoryError: Java heap space 堆空间不足
Error occurred during initialization of VM Could not reserve enough space for object heap Error: Cou ...
- 【BZOJ3387】[Usaco2004 Dec]Fence Obstacle Course栅栏行动 线段树
[BZOJ3387][Usaco2004 Dec]Fence Obstacle Course栅栏行动 Description 约翰建造了N(1≤N≤50000)个栅栏来与牛同乐.第i个栅栏的z坐标为[ ...