Supported with: ArcGIS Engine, ArcGIS Desktop, ArcGIS Server
Library dependencies: System, SystemUI, Geometry, Display, Server, Output, GeoDatabase, GISClient, DataSourcesFile, DataSourcesGDB, DataSourcesOleDB
The DataSourcesRaster library contains raster related objects in three categories: 1. Objects used for accessing raster data from various data sources including file system, Personal geodatabase, File geodatabase and ArcSDE geodatabase; 2. Objects used for geodata transformation and pixel filtering; and 3. Objects used for raster mosaicking, raster loading, and other miscellaneous objects.
The PixelFilter, GeodataXform, PixelResampler, PixelReader and MosaicOperator classes can be instantiated. Objects used for renderering raster data are located in esriCarto.lib.
The objects in this library are grouped into a number of library subsystems. They are:
Raster data consists of a rectangular array of equally spaced cells, which taken as a whole represent thematic, spectral, or picture data. Raster data can represent everything from qualities of a land surface, such as elevation or vegetation, to satellite images, scanned maps, and photographs.
ArcGIS supports file-based raster data such as GRID, TIFF, ERDAS IMAGINE, and JPEG etc. It also supports raster data in geodatabases including File geodatabase, Personal geodatabase and ArcSDE geodatabase. Regardless of the various data sources, two data types are used to represent raster data: raster datasets and raster catalogs.
A raster dataset represents one or multiple arrays of pixels as well as their associated information that are stored as a particular raster format in a storage media, such as file system or geodatabases. A raster catalog represents a collection of raster datasets. Stored as a special type of feature class in geodatabases, a raster catalog is used to manage the raster datasets as well as their associated footprints as a single entity.
A raster dataset consists of one or more raster bands. Each band in a dataset may contain the statistics and histogram of the pixel values. A raster dataset may also contain pyramids, a stack of down resampled pixels stored in the dataset and used for fast display of large raster datasets.
A single band raster dataset may contain a colormap consisting of a set of colors (red, green and blue) used in displaying the pixels and a raster attribute table that stores extra information about the pixels such as landuse type, soil type and so on.
As a type of geodataset, a raster dataset may contain a geodata transformation and a spatial reference. The geodata transformation defines how the pixels will be transformed during access and a spatial reference defines the coordinate system of the pixels that are mapped to.
If the pixels or cells of a raster dataset have missing information, those cells are called NoData cells. A file based raster dataset uses a NoData value to represent NoData, while a geodatabase raster dataset uses a bit mask to represent NoData.

A Workspace is a repository that stores geodatasets. For raster data, a Workspace can be a raster workspace (or a directory) for file-based raster data, an Access workspace for raster data in Personal Geodatabase, a File geodatabase workspace, or an ArcSDE workspace.
To access raster data, first create a Workspace, then use IRasterWorkspace2 or IRasterWorkspaceEx interface. A Workspace must be initiated from a workspace factory. The RasterWorkspaceFactory object is used to initialize a raster workspace. The AccessWorkspaceFactory object is used to initialize an Access workspace. The FileGDBWorkspaceFactory object is used to initialize a File geodatabase workspace. The SdeWorkspaceFactory object is used to initialize an ArcSDE workspace. The following functions create workspaces from difference sources, and these functions will be used through-out the whole overview.
This function opens a raster workspace from a given directory.
Public Function OpenRasterWorkspace(sPath As String) As IRasterWorkspace Dim pWKSF As IWorkspaceFactory Set pWKSF = New RasterWorkspaceFactory Dim pRasterWs As IRasterWorkspace Set pRasterWs = pWKSF.OpenFromFile(sPath, 0) Set OpenRasterWorkspace = pRasterWs End Function
The following function opens a File geodatabase workspace.
Public Function OpenFileGDBWorkspace (GDBFileName As String) As IRasterWorkspaceEx Dim pWsFact As IWorkspaceFactory Set pWsFact = New FileGDBWorkspaceFactory Set OpenFileGDBWorkspace = pWsFact.OpenFromFile(GDBFileName, 0) End Function
The following function opens an ArcSDE workspace by passing the connection information.
Public Function OpenSDERasterWorkspace(sServer As String, sInstance As String, sDB As String,
_sUser As String,sPasswd As String,sVersion As String) As IRasterWorkspaceEx
Dim pWKSF As IWorkspaceFactory
Set pWKSF = New SDEWorkspaceFactory
Dim pConn As IPropertySet
Set pConn = New PropertySet
With pConn
.SetProperty "Server", sServer
.SetProperty "Instance", sInstance
.SetProperty "Database", sDB
.SetProperty "User", sUser
.SetProperty "Password", sPasswd
.SetProperty "Version", sVersion
End With
Set OpenSDERasterWorkspace = pWKSF.Open(pConn,0)
End Function
Two interfaces of the Workspace object provide access to RasterDataset and RasterCatalog objects. IRasterWorkspace2 is used to open and create a RasterDataset from file system only; while IRasterWorkspaceEx is used to open and create both a RasterDataset and a RasterCatalog in geodatabases. Because of the different storage media, there are some variations in the ways of creating a RasterDataset in different workspaces. However once created, a RasterDataset behaves the same except for some minor differences.
The code below opens an Imagine file in a given directory.
Dim pRasterDataset As IRasterdataset
Dim pRasterWs As IRasterWorkspace
Set pRasterWs = OpenRasterWorkspace("D:\data")
Set pRasterDataset = pRasterWs.OpenRasterDataset("airphoto.img",0)
This code snippet opens a raster dataset and a raster catalog from a geodatabase.
Dim pWorkspace As IRasterWorkspaceEx
Dim pRasterDataset As IRasterDataset
Dim pRasterCatalog As IRasterCatalog
'From a File geodatabase.
Set pWorkspace = OpenFileGDBWorkspace("D:\data\fgdb_images.gdb")
'Or from an SDE geodatabase
Set pWorkspace = OpenSDEWorkspace("myserver","5151","myuser", "mydatabase","mypasswd","SDE.DEFAULT")
Set pRasterDataset = pWorkspace.OpenRasterDataset("airphoto")
Set pRasterCatalog = pWorkspace.OpenRasterCatalog("RedlandImages")
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.
Raster ub ArcSDE is stored as a set of DBMS tables that are used to manage the pixel values, pyramids, and other auxilary information. The pixels of raster data are devided 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 the business table defines the propertes of the raster dataset and the geometry column defines properties of the footprint of the raster dataset. File geodatabase raster has a similar implementation as ArcSDE geodatabase. The only difference is that raster is stored as a set of FGDB tables in 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, etc.
Since raster data in a personal geodatabase is implemented by converting it to an Imagine file format and managed internally within the personal geodatabase, only some of the raster storage properties apply to personal geodatabase such as cell size and compression.
Creating a geodatabase raster dataset using IRasterWorkspaceEx initially creates an empty raster dataset. This empty raster dataset, with no dimension, is basically a placeholder for the specified properties of the raster dataset and can be populated by mosaicking from other raster data or alternatively, writting using PixelBlock.
To create a raster dataset 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 raster dataset created has a specified dimension and a default pixel value. The default pixel value is normally the max 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 will be used. The example below creates an Imagine file with a dimension of 1024 x 1024 and a cell size of 30 meters.
Dim pRasterDataset As IRasterDataset
Dim pRasterWs As IRasterWorkspace2
Set pRasterWs = OpenRasterWorkspace("D:\data")
'The origin is the lower left corner of the dataset in map space
Dim pPoint As IPoint
Set pPoint = New Point
pPoint.PutCoords 100, 100
Set pRasterDataset = pRasterWs.CreateRasterDataset("MyImage.img", "IMAGINE Image", pPoint,
_1024, 1024, 30, 30, 1, PT_UCHAR, New UnknownCoordinateSystem, True)

The RasterDataset object represents a raster dataset stored in a storage media, a file system, a geodatabase or in memory. A RasterDataset is a file RasterDataset if it is opened from a file system or a Personal geodatabase, or is a database RasterDataset 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 file system, is also a file RasterDataset. ArcGIS 9.2 allows to create an in-memory RasterDataset where the pixels are stored in memory, this type of raster dataset has the charastics of a file RasterDataset. Regardless of the data source it is coming from, a RasterDataset behaves the same except for some minor differences.
As a type of Dataset, the RasterDataset object performs basic dataset management functions such as copy, rename, and delete. It can also be used to examine dataset properties such as raster format and compression type by using IRasterDataset interface.
A RasterDataset is a type of Geodataset and supports IGeoDataset and IGeoDataset2 interface. A RasterDataset has an extent, a spatial reference and a geodata transformation (GeodataXform). The geodata transformation is stored as special metadata of the raster dataset and is used to transform the pixels to the current extent and spatial reference. Normally, the geodata transformation is an IdentityXform which does not transformation pixels. In some cases, such as raw images with RPC (Rational Polynomial Coefficients) information or a raster dataset created using IRasterGeometryProc::Register method (e.g. using the Georeferencing tool in ArcMap), those raster datasets contain a GeodataXform, an RPCXform and a PolynomialXform respectively.
The extent and spatial reference of a raster dataset are the extent and spatial reference after the geodata transformation is applied to the dataset and they can be retrieved using the IGeoDataset interface. The extent and spatial reference before a transformation is applied are called native extent and native spatial reference. The native extent and native spatial reference can be retrieved from IGeoDataset2 interface. The following code shows the use of this interface.
Sub GetDatasetXform(pRasterDs As IRasterDataset)
Dim pGeodataset2 As IGeoDataset2
Set pGeodataset2 = pRasterDs
'get the xform, native extent and native spatial reference
Dim pXF As IGeodataXform
Dim pNativeExtent As IEnvelope
Dim pNativeSR As ISpatialReference
Set pNativeExtent = pGeodataset2.NativeExtent
Set pNativeSR = pGeodataset2.NativeSpatialReference
Set pXF = pGeodataset2.GeodataXform
End Sub
The spatial reference as well as the geodata transformation of a raster dataset can be altered using the IGeoDatasetSchemaEdit2 interface.
The IRasterDataset2 interface is used to build, add, and delete a raster table on a RasterDataset.
The IRasterDatasetEdit interface is used to add and remove a colormap of a raster dataset. You can also merge pixels from another raster dataset to the current raster dataset through IRasterDatasetEdit::Mosaic method. Assuming that a pRaster (IRaster) and pColormap (IRasterColormap) have been created, the following code snippet adds a colormap to the dataset and also mosaics from pRaster.
Dim pRasterDatasetEdit As IRasterDatasetEdit Set pRasterDatasetEdit = pRasterDataset 'Alter colormap PRastereDatasetEdit.AlterColormap pColormap 'Mosaic pixels from pRaster to the dataset pRasterDatasetEdit.Mosaic pRaster, 0.5
IRasterDataset::PrecalculateStats is used to calculate the statistics of a raster dataset at the full resolution. IRasterDatasetEdit::ComputeStas, which applies to a database RasterDataset only, is used to calculate raster statistics on a pyramid layer, e.g. skipping some pixels in the calculation. Calculating statistics on a pyramid layer reduces the computation time at the expense of providing less accurate statistics.
You can build pyramids for a raster dataset. When IRasterPyramid interface is used to build pyramids for a file RasterDataset, the resampling method used is determined automatically by the system based on the data representation type. If the data type is thematic, nearest neighbor resampling will be used; otherwise, bilinear resampling will be used. The IRasterPyramid2 interface is used for creating raster pyramids by specifying a resampling method. This interface is mostly useful for a database RasterDataset.
ISaveAs is used to perform format conversion. The supported writable formats in ArcGIS 9.2 are GRID, TIFF, Imagine, JEPG2000, JPEG, PNG, BMP, GIF, PCI, PCRaster, X11 Pixelmap, HDF4, Idrisi RST and geodatabases. It can also be written to an in-memory raster dataset. The code snippet below saves a raster dataset to an IMAGINE format.
Sub SaveAs (pRasterDs as IRasterDataset) Dim pSaveAs as ISaveAs Set pSaveAs = pRasterDs Dim pRasterWs as IRasterWorkspace Set pRasterWs = OpenRasterWorkspace(c:\data) pSaveAs.SaveAs "MyImage.img", pRasterWs, "IMAGINE Image" End sub
ISaveAs2, new at ArcGIS 9.2, can be used to specify the storage properties during saveas, such as tile size, compression type, etc. The example below saves to a raster dataset in File geodatabase with 64 x 64 tile size and a JPEG2000 compression.
Sub SaveAsWithCompression(pRasterDs As IRasterDataset)
Dim pSaveAs2 As ISaveAs2
Set pSaveAs2 = pRasterDs
set storage
Dim pStorageDef As IRasterStorageDef2
Set pStorageDef = New RasterStorageDef
pStorageDef.CompressionType = esriRasterCompressionJPEG2000
pStorageDef.CompressionQuality = 30
pStorageDef.Tiled = True
pStorageDef.TileHeight = 64
pStorageDef.TileWidth = 64
save it out
Dim pFileGDbWs As IWorkspace
Set pFileGDbWs = OpenFileGDBWorkspace("c:\data\fgdb.gdb")
pSaveAs2.SaveAsRasterDataset "filegdbRaster", pFileGDbWs, "gdb", pStorageDef
End Sub
A RasterDataset is composed of one or more persistent raster bands. You can get a RasterBand through an IRasterBandCollection::Item method. Other methods of the IRasterBandCollection interface, such as adding or removing bands, have no effect on the RasterDataset. The IRasterBandCollection::SaveAs plays the same role as ISaveAs::SaveAs.
The RasterDataset object can be used to initiate a Raster object (see Raster section). Besides being accessed through a workspace, RasterDataset may also be retrieved from a RasterBand using the RasterDataset property. To access the RasterDataset from a Raster object, first access a band from the Raster, then obtain a reference to the dataset from the band. This technique is shown here:
QI IRasterBandCollection from the Raster object Dim pBandCol As IRasterBandCollection Set pBandCol = pRaster 'Get the first band from the Raster Dim pRasterBand As IRasterBand Set pRasterBand = pBandCol.Item(0) 'Get the Rasters dataset from the band Dim pRasterDataset As IRasterDataset Set pRasterDataset = pRasterBand.RasterDataset
The RasterBand object 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 following code shows how to access a RasterBand from either a Raster or a RasterDataset object.
Dim pBandCol as IRasterBandCollection Set pBandCol = pRasterPtr 'May be a Raster or a RasterDataset ' Get the first band of the raster Dim pRasterBand As IRasterBand Set pRasterBand = pBandCol.Item(0)
The IRasterband interface provides access to the raster colormap, raster histogram, statistics, and the raster attribute table if they exist. The code snippet below accesses a raster colormap.
Sub GetRasterColormap(pRasterBand as IRasterBand) Dim pColormap As IRasterColormap Dim HasColormap As Boolean HasColormap = pRasterBand.HasColormap If HasColormap = True Then Set pColormap = pRasterBand.Colormap End Sub
A raster band contains pixel values, which can be accessed through the IRawPixels interface or through Raster object using IRasterEdit interface. The properties of the IRasterProps interface on RasterBand supports read-only with an exception of NoDataValue which is used in writing pixel blocks.
A file-based RasterBand also supports the IRasterTransaction interface which is used to manage the transaction of pixel editing.
A raster attribute table is a generic Table that stores additional information about the pixels besides pixel values, such as soil type, land use type etc. A raster attribute table is stored as a .dbf file with the same name of the dataset for file-based raster data, except for storing as a VAT for a grid, and as an internal table for raster data in geodatabases.
A raster attribute table is loosely coupled with the raster dataset (except a grid VAT). You can build a raster table for a single band raster dataset using IRasterDataset2, open a raster attribute table from a RasterBand using IRasterband::AttributeTable or a Raster using IRaster2::AttributeTable, edit the table just like you edit any generic table, and set the table to the raster dataset. Assuming that pRasterDataset is known, the code below opens a raster attribute table from a Raster.
Dim pTable As ITable Dim pRaster2 As IRaster2 Set pRaster2 = pRasterDataset.CreateDefaultRaster Set pTable = pRaster2.AttributeTable
The code below opens a raster attribute table from a raster band.
Dim pTable As ITable Dim pRasterBand As IRasterBand Dim pBandCol As IRasterBandCollection Set pBandCol = pRasterDataset Set pRasterBand = pBandCol.Item(0) Set pTable = pRasterBand.AttributeTable
RasterStatistics object represents the statistical information of the pixel values of a raster band. It is not co-creatable and can be retrieved from a RasterBand. The IRasterStatistics interface can be used to calculate the statistics of a raster band with some special settings, for example it allows to ignore certain pixels by setting the pixel values using IgnoreValue property, or skip some rows and columns by setting the skip factors in the calculation. The code below gets a RasterStatistics from a RasterBand and retrieves statistics information.
Sub GetRasterStats(pRasterDataset As IRasterDataset)
Dim pRasterStats As IRasterStatistics
Dim pBandCol As IRasterBandCollection
Dim pBand As IRasterBand
Set pBandCol = pRasterDataset
Set pBand = pBandCol.Item(0)
Set pRasterStats = pBand.Statistics
pRasterStats.SkipFactX = 100
pRasterStats.SkipFactY = 100
pRasrerStats.Recalculate
End Sub
RasterHistograms object represents the histogram information of the pixel values of a raster band. It is not co-creatable and can be retrieved from a RasterBand using IRasterBand::Histogram method.
The RasterColormap object contains a collection of colors that are represented in a red, green and blue form. It can be co-created, retrieved from a RasterBand using IRasterBand::Colormap or retrieved from a Raster using IRaster2::Colormap. You can also set the colormap of a dataset through IRasterDatasetEdit interface.
The Raster object, in contrast to the static RasterDataset and RasterBand objects, is transient in nature and can be modified without affecting the source data. This allows the Raster to represent what you want, as you may set a transformation or a pixel filter on a raster, specify a projection, extent, and other properties without actually changing the raster dataset. If you want to persist change, the modified Raster can be saved to another raster dataset using ISaveAs interface.
Although Raster object is always transient in nature, it must be associated with one or more raster bands, which provide a source for 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.
A Raster can be created from a RasterDataset in two ways. The IRasterDataset2::CreateFullRaster method creates a Raster with all the properties from the raster dataset, such as number of bands, width and height of the raster dataset. The IRasterDataset::CreateDefaultRaster method creates a Raster that has a square cell size and contains only three raster bands even if the dataset has more than three bands. The three bands are the default bands used in the raster RGB renderer and are determined by the settings for default raster behavior made on the RasterDefaultsEnv object in the esriCarto library.
Dim pRaster As IRaster Set pRaster = pRasterDataset::CreateDefaultRaster Dim pRasterDataset2 As IRasterDataset2 Set pRasterDataset2 = pRasterDataset Set pRaster = pRasterDataset2.CreateFullRaster
A Raster may be obtained from a RasterLayer, an object in the esriCarto library.
Set pRaster = pRasterLayer.Raster
A Raster is also co-creatable. Cocreating a Raster results in an empty raster that is not useful until one or more bands are placed into the raster, providing data for the raster to read. Creating a new raster and populating it with the desired bands provides flexibility. Any time a band is added or removed from a raster, its default settings for spatial reference, extent, and cell size may be changed, and these default settings will be applied to the Raster if they have not been previously set by the user.
Dim pRasterBandCol As IRasterBandCollection Set pRasterBandCol = New Raster pRasterBandCol.AppendBands pRasterDataset
IRasterProps is an important interface that is used to get and set the properties of the Raster, such as extent, width, height, spatial reference, pixel type, NoData value, etc. Resampling occurs when the Raster is changed geometrically such as setting an extent, a spatial reference or a geodata transformation. In this case, IRaster::ResampleMethod can be used to specify the resampling method and it will be applied during SaveAs or raster display.The code below projects the Raster by setting a new spatial reference and calling SaveAs. To project a raster with a specified datum transformation, IRaster2::GeoTransformations should be used.
Sub SetRasterProperties(pRaster as IRaster, pSR as ISpatialReference) Dim pRasterProps As IRasterProps Set pRasterProps = pRaster pRaster.ResampleMethod = RSP_BilinearInterpolation pRasterProps.SpatialReference = pSR Dim pSaveAs As ISaveAs Set pSaveAs = pRaster pSaveAs.SaveAs "MyRaster", pRasterWs, "GRID" End Sub
You can get the cell size of a Raster. However, setting a cell size to a Raster should be done by adjusting the width, height, and extent of the Raster. If the height and/or width are changed, the cell size of the Raster will be re-calculated by using the new height and width to divide the current raster extent. In this case, it will most likely result in a Raster with non-square cell size. You can SaveAs a Raster with square cell size by specifying a pre-calculated height and width .
A Raster can be transformed geometrically by setting a GeodataXfrom using IRaster2. To save a transformed raster, the user must transform the extent and cell size using the GeodataXform of the Raster and set the transformed extent and cell size on the Raster.
Sub SetAndSaveAsXform(pRaster As IRaster2, pXF As IGeodataXform)
'get the raster's extent and cell size
Dim pRasterProp As IRasterProps
Dim pExtent As IEnvelope
Dim xCell As Double, yCell As Double
Set pRasterProp = pRaster
Set pExtent = pRasterProp.Extent
xCell = pRasterProp.MeanCellSize.x
yCell = pRasterProp.MeanCellSize.y
'set the xform
pRaster.GeodataXform = pXF
'transform cell size first, then extent. The sequence matters
pXF.TransformCellsize esriTransformForward, xCell, yCell, pExtent
pXF.TransformExtent esriTransformForward, pExtent
'Put the transformed extent and cell size on the raster and saveas
pRasterProp.Extent = pExtent
pRasterProp.Width = pExtent.Width / xCell
pRasterProp.Height = pExtent.Height / yCell
Dim pSaveAs As ISaveAs
Set pSaveAs = pRaster
pSaveAs.SaveAs "c:\temp\image1.img", Nothing, "IMAGINE Image"
End Sub
The MapToPixel and PixelToMap methods are used to perform a transformation between pixel and map space. you can get the column and row in pixel space by passing x and y coordinates in map space and vice versa. The GetPixelValue can be used to identify a pixel value on a Raster by specifying the column and row of the pixel. The code below identifies a pixel value of the first band by passing in the x and y coordinates in map space.
Sub IdentifyOnRaster(pRaster as IRaster, x_map as double, y_map as double) Dim pRaster2 As IRaster2 Dim col As Long, row As Long Dim IdentifyValue As Variant Set pRaster2 = pRaster col = pRaster2.ToPixelColumn(x_map) row = pRaster2.ToPixelRow(y_map) IdentifyValue = pRaster2.GetPixelValue(0, col, row) End Sub
The Raster can be transformed radiometrically by setting a PixelFilter using the IPixelOperation interface. Example below sets a low pass filter on a Raster
Sub SetFilter(pRaster As IRaster) 'Create a PixelFilter Dim pPixelFilter As IStockConvolutionFilter Set pPixelFilter = New RasterConvolutionFilter pPixelFilter.Type = esriRasterFilterSmoothing3x3 'Set the pixel filter to the Raster Dim pPixelOp As IPixelOperation Set pPixelOp = pRaster Set pPixelOp.PixelFilter = pPixelFilter End Sub
The pixel values of the Raster can be modified and written directly to the raster bands of the raster dataset using the IRasterEdit interface (See Pixel blocks section for more detail). A Raster can be displayed using a RasterLayer object and various raster renderer objects in the esriCarto library.
A PixelBlock 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 object is designed to handle generic pixel arrays from any raster data source. To support different pixel types, the PixelBlock transports pixels in a SafeArray, which has the ability to contain many different data types.
The PixelBlock object is used to read, modify, and write pixel values or a portion of pixel values of the raster data. To work with a pixel block, first create a PixelBlock from a Raster using IRaster::CreatePixelBlock method. This will initialize the size and other properties of the pixel block. Next use IRaster::Read method to read pixel values into the pixel block, then use IPixelBlock3::PixelData or PixelDataByRef to get or modify pixel values of the pixel block. The IRasterEdit interface can be used to write the pixel block to the raster dataset.
Sub UsingPixelBlock(pRaster As IRaster)
'Define the size of the pixel block
Dim pSize As IPnt
Set pSize = New Pnt
pSize.SetCoords 256, 256
'Create the pixel block
Dim pPixelBlock As IPixelBlock3
Set pPixelBlock = pRaster.CreatePixelBlock(pSize)
' Read pixels from a starting pixel (10,10)
Dim pTopLeft As IPnt
Set pTopLeft = New Pnt
pTopLeft.SetCoords 10, 10
pRaster.Read pTopLeft, pPixelBlock
'modifies the pixel values of the pixel block
Dim pixelvalues As Variant
pixelvalues = pPixelBlock.PixelDataByRef(0)
pixelvalues(5, 5) = 10
'write the modified pixel block to the raster dataset through Raster object
Dim pRasterEdit As IRasterEdit
Set pRasterEdit = pRaster
pRasterEdit.Write pTopLeft, pPixelBlock
End Sub
For a small raster dataset, the size of the pixel block can be the size of the entire dataset, which can usually be held in memory at one time. When working with large raster data, the best practice is to divide the raster into small pixel blocks and perform reading and writing pixels block by block using the RasterCursor Object.
The IRaster::CreateCursor method provides a simple way to create a RasterCursor based on a pixel block that has the width of the whole raster and a heigh of 128. The IRaster2::CreateCursorEx method allows you to create a raster cursor with a user specified pixel block size or system provided pixel block size (pass nothing to the pixel block size).
Some pixels in a raster dataset might have missing information, and these pixels or cells are called NoData. For a file-based RasterDataset, NoData is stored as a value, called NoData value, in the raster dataset. The pixels that have the same value as the NoData value are NoData pixels. For a database RasterDataset, NoData pixels are stored as a bit mask, a two dimensional array of 0s and 1s, where 0 represents that the corresponding pixel is a NoData pixel.
IRasterProps::NoDataValue can be used to get and set the NoData value on a Raster. The NoData value will be utilized in saving (SaveAs) to a new dataset.
IRasterProps::NoDataValue can also be used to get and set the NoData value on a RasterBand. The NoData value will be utilized in writing pixel blocks to the raster dataset with IRasterEdit or IRawPixels intereface. For mask based NoData, the IPixelBlock3::Mask method should be used to set NoData when writing pixel blocks. The following example sets the NoData value on a Raster and saves it to a new raster dataset.
Sub SaveAsRasterWithNoData(pRaster)
Dim pProp As IRasterProps
Dim pSaveAs As ISaveAs
Set pProp = pRaster
'set NoData value
pProp.NoDataValue = 255
'or define different NoData values for each band.
Dim Value(2) As Integer
Value(0) = 1: Value(1) = 1: Value(2) = 32
pProp.NoDataValue = Value
'SaveAs
Set pSaveAs = pRaster
pSaveAs.SaveAs "c:\temp\nodata.img", Nothing, "IMAGINE Image"
End Sub
RasterCatalog, a special type of FeatureClass in geodatabases, manages a collection of raster datasets as one entity. It has a Name field that stores the name of the raster dataset, a Geometry field that stores the footprint (bounding box) of the raster dataset, and a Raster field that stores the pixel values of the raster dataset. It may also contain any other fields such as metadata field, text field, etc. Only one Raster field is allowed in a raster catalog.
The Raster field of a raster catalog has a spatial reference, defined by RasterDef, which serves as a default for loading raster datasets that have unknown spatial reference. In ArcGIS 9.2, the raster datasets inside a raster catalog are allowed to store their own spatial references and geodata transformations.
In addition to defining the spatial reference for the raster field, RasterDef also defines how the raster values are managed in the raster catalog. A managed raster catalog stores raster value internally inside the raster catalog. An unmanaged raster catalog stores only the paths to the raster datasets, and those raster datasets may reside in file system. A raster catalog in an enterprise geodatabase is always managed.
The footprints of the raster datasets stored in the Geometry field are automatically managed, populated and spatially indexed by the geodatabase. The spatial reference (the projected or geographic coordinate system, the coordinate domain and the coordinate precision) and the spatial index of the geometry field can be set using a GeometryDef object.
The value stored in the Raster field is called a RasterValue. A RasterValue contains a RasterDataset and a RasterStorageDef that describes how the RasterDataset is stored in the geodatabase. You can specify the tile size, cell size, origin of the raster dataset. You can also define the compression type as well as the resampling method for pyramids building.
As a subclass of FeatureClass, the RasterCatalog consists of rows. Each row is a RasterCatalogItem, which is a type of Feature. A RasterCatalog operates the same way as a FeatureClass when accessing or updating the raster datasets in the RasterCatalog (e.g., enumeration of the raster datasets in a RasterCatalog is accomplished by acquiring a standard FeatureCursor on the RasterCatalog). Insert and update can be achieved by an insert cursor or an update cursor.
To create a raster catalog, first create an empty raster catalog with defined fields, and then add rows that contain raster values to the raster catalog. The following code snippet shows a way of loading a raster dataset to a raster catalog and retrieve a raster dataset inside a raster catalog.
'Create RasterValue from RasterDataset Dim pRasterValue As IRasterValue Set pRasterValue = New RasterValue Set pRasterValue.RasterDataset = pRasterDataset 'Raster catalog is a type of feature class Dim pFeatureClass As IFeatureClass Set pFeatureClass = pRasterCatalog 'Insert a row and set the raster value Dim pCursor As IFeatureCursor Dim pRow As IFeatureBuffer Set pCursor = pFeatureClass.Insert(False) Set pRow = pFeatureClass.CreateFeatureBuffer pRow.Value(pRasterCatalog.RasterFieldIndex) = pRasterValue pCursor.InsertFeature pRow
The code below shows how to get the raster dataset stored in first row in a raster catalog:
Dim pFeatureClass As IFeatureClass Set pFeatureClass = pRasterCatalog Dim pCatalogItem As IRasterCatalogItem Set pCatalogItem = pFeatureClass.GetFeature(1) Set pRasterDataset = pCatalogItem.RasterDataset
A RasterCatalog can be displayed using the GdbRasterCatalogLayer, an object in esriCarto library.
A geodata transformation is a mathematical operation that is used to perform geometric transformations for geodatasets such as raster datasets. ArcGIS 9.2 supports many geodata transformations including coordinate transformation (re-projection), polynomial transformation, rubber sheeting (Adjust) transformation, Spline transformation, RPC (Rational Polynomial Coefficients) transformation and so on. The geodata transformations are represented as an abstract class, GeodataXform, and 10 concrete geodata transformation objects (Xform), which include AdjustXform, SplineXform, RPCXform, PolynomialXform, CoordinateXform, ApproximationXform, GCSShiftXform, GeometricXform, CompositeXform, and IdentityXform. The user can also create a custom Xform by implementing interfaces of the GeodataXform abstract class.

All GeodataXforms can have an output spatial reference that defines the spatial reference of the data after being transformed (e.g. in output space). The domains of GeodataXforms, if they exist, are also defined in the output space. All GeodataXforms perform point (IPointCollection or WKSPoint) transformation, extent (IEnvelope) transformation and cell size transformation in forward and backward directions. To transform raster data, the RasterXformer, discussed at the end of this section, provides the mechanism behind the scenes by calling PixelReader, PixelResampler and IRasterXform. The IRasterXform interface is used for those geodata transformations that need raster specific information to optimize the operations. Therefore, creating a custom geodata transformation to work with raster data should implement the IRasterxform interface.
The following code snippet transforms a collection of points. Note that the point collection, extent and cell size are transformed by reference, e.g, the input and output use the same variable.
Sub TransformPoints(pXF as IGeoDataXform, pPointCol As IPointCollection, pExtent as Ienvelope, xcell as Double, ycell as Double)
pXF.TransformPoints esriTransformForward, pPointCol
pXF.TransformCellSize esriTransformForward, xcell, ycell, pEnv
pXF.TransformExtent esriTransformForward, pEnv
End Sub
A GeodataXform is stored as a metadata of the raster dataset and can be modified using IGeodataSchemaEdit2::AlterGeodataTransformation (see raster dataset section). The GeodataXform of a raster dataset will be applied to transform the pixels on-the-fly during raster layer display. You can also set a GeodataXform on a Raster and persist the transformed Raster using ISaveAs (see more information in the Raster section). SaveAs a RasterDataset will not apply the GeodataXform to the pixels, but will persist the GeodataXform with the output raster dataset.
The PolynomialXform performs transformation using a polynomial, which is built based on a LSF (Least Square Fitting) algorithm. A PolynomialXform can be defined in two ways. One is to use two sets of control points, one being source and one being target, to construct the polynomial of an order of 1,2, or 3. The minimum number of the non-correlated control points required for this method must be 3, 6, and 10 respectively. The other way is to set the polynomial coefficients directly using the IPolynomialXform::DefineFromCoefficients if the polynomial coefficients are known.
A polynomial transformation is an approximate transformation and the IPolynomialXform interface provides two ways to calculate the system residuals and RMS. One is based on the control points using GetSystemResidual and GetSystemRMS methods; and the other is based on a set of check points using CheckResidualRMS method. Assuming pSourcePoints and pTargetPoints are known source and target control point collections, the code snippet below creates a polynomial xform.
Dim pPolyXform As IPolynomialXform Set pPolyXform = New PolynomialXform 'assuming the input point collections contain at east 6 points each pPolyXform.DefineFromControlPoints pSourcePoints, pTargetPoints, 2
The SplineXform object performs a geodata transformation using a Spline function, a piecewise polynomial that maintains continuity and smoothness between adjacent polynomials. It transforms the source control points exactly to the target control points, while the points or pixels that are away from the control points are not always guaranteed to have higher accuracy. Spline transformation is useful when the control points are very important and required to be registered precisely. Adding more control points can increase an overall accuracy of the Spline transformation. A SplineXform object can be created from two sets of control points using the DefineFromControlPoint method of ISplineXform interface.
The AdjustXform, also called a rubber sheeting transformation, is built upon an algorithm that combines a polynomial transformation and a TIN interpolation technique. Adjust transformation first performs a polynomial transformation using two sets of control points, then adjusts the control points locally to better match the target control points using a TIN interpolation technique. Comparing to the PolynomialXform and SplineXform, AdjustXform has both the characteristics of global optimization (because of the use of LSF algorithm) and local accurate approximation of the control points. Assuming pSourcePoints and pTargetPoints are known source and target control point collections, code snippet below creates an AdjustXform object using IAdjustXform interface.
Dim pAdjustXF As IAdjustXform Set pAdjustXF = New AdjustXform 'set control points and polynomial order used pAdjustXF.DefineFromControlPoints pSourcePoints, pTargetPoints pAdjustXF.PolynomialApproximation = 2 'use interpolation to do the adjustment pAdjustXF.NaturalNeighbor = True
The ApproximateXform is used to perform an approximate transformation of a GeodataXform to achieve a better performance and it is mainly for those GeodataXforms that are computationally expensive such as CoordinateXform, AdjustXform, etc. An ApproximateXform has an associated GeodataXform, a user defined point grid (or mesh) and a tolerance. ApproximateXform approximates its base GeodataXform by applying the true transformation only on the coarse mesh, and performing bilinear interpolation for between points. It guarantees the approximation error does not exceed the specified tolerance. The Code below creates an ApproximateXform object using IApproximateXform and IGeodataXformApproximation interfaces
Sub CreateApproximationXform(pXF As IGeodataXform)
Dim pApproximateXF As IApproximationXform
Dim pGeodataXFApp As IGeodataXformApproximation
Set pApproximateXF = New ApproximationXform
Set pApproximateXF.GeodataXform = pXF
Set pGeodataXFApp = pApproximateXF
pGeodataXFApp.Tolerance = 0.5
pGeodataXFApp.GridSize = 32
End Sub
Sub TransformPointsWithCoordinateXForm(pSourceSR As ISpatialReference, pTargetSR As ISpatialReference, pPointCol As IPointCollection)
'Create the CoordinateXform
Dim pCoorXform2 As ICoordinateXform2
Set pCoorXform2 = New CoordinateXform
'Set source and target spatial reference
Set pCoorXform2.SpatialReference = pTargetSR
Set pCoorXform2.InputSpatialReference = pSourceSR
Define approximation parameters
Dim pApproximate As IGeodataXformApproximation
Set pApproximate = pCoorXform2
pApproximate.Approximation = True
pApproximate.GridSize = 16
pApproximate.Tolerance = 15 'unit in the input space
'The points will be transformed to a target spatial reference after this call
pCoorXform2.TransformPoints esriTransformForward, pPointCol
End Sub
Some image products delivered from satellite image companies such as Digital Globe or Space Imaging contain RPC (Rational Polynomial Coefficients) information within the image data. The RPC, represented as 92 parameters, defines the transformation to be used for image registration. The RPCXform object is used to support RPC transformation and image orthorectification.
To create an RPCXform, besides setting the 92 coefficients using IRPCXform, you must also set the forward transformation since RPC only defines the reverse transformation (ground to image). The ISensorXform interface is used to set the elevation information to perform image orthorectification.
GCSShiftXform is used to perform transformation from a non-standard GCS coordinate (0 to 360) to a standard GCS (180 to 180). For example, if your world image comes in a coordinate system of (0,360, -90 , 90), the GCSShiftXform can be used to transform your image to (-180, 180, -90,90).
The GeometricXform is a geodata transformation based on the transformation objects defined in the Geometry library (AffineTransformation2D, ProjectiveTransformation2D, etc.). It is a wrapper of these classes and allows these classes to be incorporated in the geodata transformation pipeline.
The IdentityXform object is an identity coordinate transformation that has no effect on coordinates and is used purely to associate or change the spatial reference of the data. A raster dataset created from RasterGeometryProc::Rectify has an identity transformation, while a raster dataset created from RasterGeometryProc::Register has a polynomial transformation.
The CompositeXform consists of a set of ordered xforms and it is used to manage the xform list. For example to add, remove, or get a geodata xform. The sequence of the transformation being applied is from bottom to top for forward transformation, and top to bottom for reverse transformation.
To transform raster data with these geodata xforms, the RasterXformer object plays a critical role behind the scenes. A RasterXformer contains a GeodataXform, a PixelResampler, and a PixelReader. It also contains the logic to drive these three components to perform raster transformations. Raster transformation is a reverse transformation. For a given extent (Envelope) in the output space, the RasterXformer first rasterizes it into pixels, then reverse transforms the pixels into the input space using the GeodataXform. Finally it resamples the pixels, provided by the PixelReader, in the input space using the PixelResampler. If an approximation is used in the transformation, only pixels on a predefined mesh will be reversely transformed to the input space, and the values of the pixels inside the mesh will be interpolated.
The default pixel reader used by the RasterXformer is a SimplePixelReader, and it provides input pixels, either from a Raster object or from raw pixel read by implementing a call back function using the IRawPixelReader interface. If the input pixels are not coming from a Raster, IRasterXformer2 can be used to dynamically transform pixels, such as on-fly-projected pixels from ArcIMS layer. In this case, the developer is responsible for setting up a custom PixelReader.
The default pixel resampler used by the RasterXformer is a SimplePixelResampler, which supports four types of resampling methods (Nearest Neighbor, Bilinear Resampling, Cubic Convolution, and Majority). You can modify the properties of the SimplePixelResampler. The following example sets the cubic convolution parameter to be 0.5.
Private Sub SetCubicResamplingFactor(pRaster As IRaster)
Dim pRasterXformer As IRasterXformer
Dim pSimpleResampler As ISimplePixelResampler
Dim pRaster2 As IRaster2
'set raster resampling method
pRaster.ResampleMethod = RSP_CubicConvolution
'get the transformer and resampler
Set pRasterXformer = pRaster2.RasterXformer
Set pSimpleResampler = pRasterXformer.PixelResampler
'set the factor
pSimpleResampler.CubicConvolutionParameter = -0.5
End Sub
The pixel filter objects perform radiometric transformation which transforms pixel values. The PixelFilter, an abstract class, supports the IPixelFilter and IPixelFilter2 interfaces and is implemented by seven pixel filter objects: RasterConvolutionFilter, PanSharpeningFilter, BackgroundFilter, ColormapFilter, LutFilter, MultibandFilter, RemapFilter, and a PixelFilterCollection object which allows you to define more than one pixel filter operations on a pixel block. You can also create a custom filter by implementing the IPixelFilter interface.
The PanSharpeningFilter object, new at ArcGIS 9.2, is used to perfomen image enhancement using various panchromatic sharpening techniques . Panchromatic sharpening uses a higher-resolution panchromatic image (or raster band) to fuse with a co-registered lower-resolution multiband raster dataset. The result of this will produce a multiband raster dataset with the resolution of the panchromatic raster where the two rasters fully overlap. IPansharpeningFilter is used to create a PansharpeningFilter object, setting a panchromatic raster and specifying a pan-sharpening type.
ArcGIS 9.2 provides four pan-sharpening methods: Mean, Brovey, IHS, and ERSI pansharpening. These methods are all based on the following general model:
A pixel value of a Pan image is considered a weighted average of red, green, blue, and (optional) infrared components:
The RasterConvolutionFilter object is used to perform various pixel filtering techniques to enhance image. The IStockConvolutionFilter interface provides access to many existing convolution filters such as low pass filter, high pass filter, etc. The IRasterConvolutionFilter interface allows you to create your own convolution filter by defining a kernel. Code snippet below creates a convolution filter with a 3x3 kernel.
Dim pFilter As IRasterConvolutionFilter
Set pFilter = New RasterConvolutionFilter
Dim Kernel(2, 2) As Double
Kernel(0, 0) = -1
Kernel(0, 1) = -1
Kernel(0, 2) = -1
Kernel(1, 0) = 2
Kernel(1, 1) = 2
Kernel(1, 2) = 2
Kernel(2, 0) = -1
Kernel(2, 1) = -1
Kernel(2, 2) = -1
pFilter.PutCoefficients Kernel
The pixel filter can be set on a Raster, and the pixel values of the raster will be transformed by the pixel filter when saving out to a raster dataset or sending to the display. The code example below creates a 3x3 filter and applies it to a Raster.
Sub SetFilterOnRaster(pRaster as IRaster) Dim pFilter As IStockConvolutionFilter Set pFilter = New RasterConvolutionFilter pFilter.Type = esriRasterFilterSharpening3x3 Dim pPixelOperation As IPixelOperation Set pPixelOperation = pRaster Set pPixelOperation.PixelFilter = pFilter End Sub
This part includes objects used for mosaicking raster datasets, loading raster datasets and raster catalogs, and conversion. It also contains other miscellaneous objects.
MosaicRaster and RasterLoader objects are used to mosaic raster data.
MosaicRaster mosaics a collection of raster datasets and saves the result to a new seamless raster dataset. MosaicRaster also takes a raster catalog as an input, and mosaics all raster datasets or a portion of raster datasets in a raster catalog, defined by a WhereClause, into a single raster dataset. You can control how the overlapped pixels are resolved by specifying MosaicOperatorType or by creating a custom operator by implementing the MosaicOperator class. You can also control the output colormap for mosacking colormapped raster datasets.
The MosaicRaster object supports the IRasterProps interface which allows you to control the properties of the output raster dataset such as pixel type, cell size, NoData etc. By default, the output raster takes the properties from the first raster to be mosaicked except taking the union of extents of all rasters. The MosaicRaster object also supports the ISaveAs interface, allowing you to create a mosaic output to a file-based raster or to a raster dataset in geodatabase. The example below creates one seamless raster dataset from a subset of raster datasets in a raster catalog.
This example below creates one seamless raster dataset from a subset of raster datasets in a raster catalog:
Dim pWorkspace As IRasterWorkspaceEx
Dim pInCatalog As IRasterCatalog
'Open raster catalog
Set pWorkspace = OpenAccessRasterWorkspace("d:\data\pgdb.mdb")
Set pInCatalog = pWorkspace.OpenRasterCatalog("mycatalog")
'Initialize MosaicRaster
Dim pMosaicRaster As IMosaicRaster
Set pMosaicRaster = New MosaicRaster
'Assign RasterCatalog to MosaicRaster and define a whereclause
pMosaicRaster.RasterCatalog = pInCatalog
pMosaicRaster.WhereClause = "state = 'CA'"
'Save to a raster dataset
Dim pSaveAs As ISaveAs
Dim pDataset As IRasterDataset
Set pSaveAs = pMosaicRaster
Set pDataset = pSaveAs.SaveAs("MosaicOutput", pWorkspace, "SDR")
And the code below mosaic two rasters, assuming pRaster1 and pRaster2 have been created, to an Imagine file:
Dim pRasterCol As IRasterCollection
Dim pSaveAs As ISaveAs
Dim pMosaicRaster As IMosaicRaster
Set pMosaicRaster = New MosaicRaster
Set pRasterCol = pMosaicRaster
pRasterCol.Append pRaster1
pRasterCol.Append pRaster2
Set pSaveAs = pMosaicRaster
pSaveAs.SaveAs "output.img", OpenRasterWorkspace("D:\data"), "IMAGINE Image"
The RasterLoader object is used to mosaic raster data, in any format, to an existing raster dataset. Thie method works if the existing raster datasets are in any of the supported writable formats, but it works better for ArcSDE or File geodatabase raster datasets. This RasterLoader allows you to specify certain properties during data loading such a background value to be ignored, the output colormap , and etc. This object extends the functionality of IRasterDatasetEdit::Mosaic by allowing to specify more properties for mosacking operation.
MosaicColormapMode sets the operation mode for colormap manipulation.
Background sets the background value of the input raster to be ignored when loading.
Foreground, set to 255, instructs the loader to load 1 bit raster into an 8 bit raster dataset in order to achieve better display effect.
PixelAlignmentTolerance sets the tolerance for resampling
The code below mosaics a raster (pRaster) to a raster dataset (pRasterDataset) and use the colormap on the raster.
Dim pRasterLoader As IRasterLoader Set pRasterLoader = New RasterLoader pRasterLoader.MosaicColormapMode = MM_LAST pRasterLoader.Load pRasterDataset, pRaster
In ArcGIS 9.2, two loader objects are available to facilitate raster catalog loading. They are RasterCatalogLoader and DrLoader (Distributed Raster Catalog Loader). The RasterCatalogLoader is an object for loading a set of raster datasets or a directory of raster datasets to a geodatabase raster catalog. Since ArcGIS 9.2 supports persisting transformation with raster datasets in a raster catalog, and allows the spatial references of the raster datasets to be different from the spatial reference of the raster column, the IRasterCatalogLoader interface can be used to load these raster datasets to a geodatabase raster catalog with options of either applying the transformation and/or re-projection to the output dataset during the loading or persisting the transformation and/or spatial reference as the properties of the raster dataset.
Assuming a directory contains images of UTM Zone 16 and UTM Zone 17, the following code loads those images to a raster catalog by preserving their original spatial reference. Setting Projected to be true will project the images to the spatial reference defined in the raster field.
Sub RasterCatalogLoader(pPropSet As IPropertySet)
'Define the storage property
Dim pStorageDef As IRasterStorageDef
Set pStorageDef = New RasterStorageDef
pStorageDef.CompressionType = esriRasterCompressionLZ77
'Set the loader
Dim pCatalogLoader As IRasterCatalogLoader
Set pCatalogLoader = New RasterCatalogLoader
Set pCatalogLoader.ConnectionProperties = pPropSet
Set pCatalogLoader.StorageDef = pStorageDef
'Set not to project the raster dataset
pCatalogLoader.Projected = False
'Load
pCatalogLoader.Load "State_catalog", "C:\data", Nothing
End Sub
When creating a raster catalog of RPC images, you can set IRasterStorageDef::Transformed to be false to persist the RPCXform with the raster datasets during the loading.
DrLoader is used to load raster datasets or a directory of raster datasets to a raster catalog. It is designed for the ArcGIS server environment where there are multiple containers. DrLoader distributes the loading tasks to all the worker machines to reduce loading time through parallel loading.
The RasterGeometryProc object is used to perform polynomial transformations such as flip, rotate, warp, etc. It can also project rasters from one spatial reference to another. The RasterGeometryProc is built based on the PolynormialXform object, but provides easy to use methods for end users.
The RasterGeometryProc manipulates only Raster object, not RasterBand or RasterDataset. This is because the Raster is transient, as are the effects of the RasterGeometryProc. This means that any transformation will also go away when the Raster object goes out of scope.
To keep the transformed data for later use, you must persist the transformation using Register or Rectify method. Register persists the transformation into the auxiliary file associated with the input dataset, which prevents the need for resampling. Rectify persists the transformed Raster into a new file. Aternatively you can use ISaveAs to save to a new raster dataset. If used on a Raster contained within a RasterLayer, processing performed by this object will be visible when the display is refreshed. Utilizing IRasterGeometryProc interface, the code below rotates a raster based on the center of the raster and persists the transformation to the same dataset.
Sub RegisterRaster(pRaster as IRaster) Dim pRasGeometryProc As IRasterGeometryProc3 Set pRasGeometryProc = New RasterGeometryProc pRasGeometryProc.Rotate Nothing, 45, pRaster PRasGeometryProc.Register pRaster End Sub
The ProjectFast method projects a raster to a new projection with a specified cell size. In ArcGIS 9.2, raster projection is built upon a point-to-point approximation algorithm that performs fast and accurate re-projection of raster data. The algorithm projects pixels on a predefined 16x16 mesh using a point-to-point projection. It then transforms the pixels inside the mesh using a bilinear interpolation technique if the error on a sub mesh is within a tolerance of half pixel, otherwise it projects the rest pixels using a point-to-point projection. Since pixels on a sub mesh will also be projected using point-to-point projection during the estimation of the interpolation accuracy, the algorithm performs point-to-point projection on a finer grid mesh and results in a much higher accuracy than the default half-pixel tolerance.
When more than one domains is involved in the raster datasets such as raster datasets with Cube projection, Fuller projection or projection with non-zero central meridian, the algorithm will divide the output space into contiguous domains by overlaying input and output domains and project pixels in each domain. This algorithm maintains the integrity of the raster dataset and guarantees that there is not discontinuity in the output raster dataset.
The RasterColormapToRGB object is used to convert between a raster dataset that contains a colormap and a three-band raster dataset.
The following example converts a colomapped raster dataset (pRasterDataset) into a RGB raster dataset.
Dim pRasterConverter As IRasterColormapToRGBConversion
Set pRasterConverter = New RasterColormapToRGBConverter
Dim pRaster As IRaster
Set pRaster = pRasterConverter.CreateRGBRaster(pRasterDataset)
Dim pSaveAs As ISaveAs
Set pSaveAs = pRaster
pSaveAs.SaveAs "RGBImage.img", OpenRasterWorkspace("d:\data"), "IMAGINE Image"
RasterCatalogTable is a legacy object used to represent a table based raster catalog, and SdeRasterCatalogTable is used for the 8.x style raster catalogs.
The RasterDomainExtractor object extracts a polygon boundary, from a raster, along the borders of pixels that are not NoData (value pixels).
RasterPicture can load a raster into a Picture object.
UniqueValues, StatsHistogram, RasterCalcStatsHistogram, and RasterCalcUniqueValues are helper objects for raster renderers, which are in esriCarto library.
DERasterDataset, DERasterBand and other data element objects are used in scripting language in GeoProcessing.