Abstract: The use of ArcGIS Engine raster data is summarized. A raster data set consists of one or more rasterbands. One band is a data matrix. For grid data (DEM data) and image data in a single band, it is represented as a raster dataset with only one band of data, however, multi-spectral image data is represented by raster datasets with multiple bands. Rastercatalog is used to display various adjacent raster data in a study area. The adjacent raster data is not spliced to form a large image... I have been dealing with raster data for two weeks and should have some understanding of the raster part of AO. Here is my own experience. Hope you can give me some advice :-)
1. Storage Type of raster data
Grid Data can generally be stored as ESRI grid (composed of a series of files), Tiff format (including a tif file and an aux file ), imagine image format in AE generally calls the isaveas interface to save Raster Data
2. Differences between raster datasets and raster catalogs
A raster dataset consists of one or more rasterbands. A band is a data matrix. For grid data (DEM data) and image data in a single band, it is represented as a raster dataset with only one band of data, however, multi-spectral image data is represented by raster datasets with multiple bands.
Rastercatalog is used to display various adjacent raster data in a study area. These adjacent raster data is not spliced to form a large image.
3. Differences between irasterworkspaceex and irasterworkspace and irsterworkspace2
1). the irasteworkspaceex interface is mainly used to read the grid data set and grid Cataloguing in Geodatabase.
2). irasterworkspace and irsterworkspace2 are mainly used to read local raster data stored in the file format.
4. Load the Raster Data (take the local raster data file as an example)
1. Use the irasterlayer interface to open a grid file and load it to the map control.
Irasterlayer rasterlayer = new rasterlayerclass ();
Rasterlayer. createfromfilepath (filename); // filename indicates the path of the local grid file.
Axmapcontrol1.addlayer (rasterlayer, 0 );
2. Use the irasterdataset interface to open a raster dataset.
Iworkspacefactory workspacefactory = new rasterworkspacefactory ();
Iworkspace;
Workspace = workspacefactory. openfromfile (inpath, 0); // inpath
If (workspace = NULL)
{
Console. writeline ("cocould not open the workspace .");
Return;
}
Irasterworkspace rastwork = (irasterworkspace) Workspace;
Irasterdataset rastdataset;
Rastdataset = rastwork. openrasterdataset (inname); // inname raster file name
If (rastdataset = NULL)
{
Console. writeline ("cocould not open the raster dataset .");
Return;
}
5. How to read the properties of raster data and traverse Raster Data
The properties of raster data include the grid size, number of rows, number of columns, projection information, and grid range. See the following code.
(Assume that the currently loaded raster value is stored in the ushort type)
Irasterprops rasterprops = (irasterprops) clipraster;
Int dheight = rasterprops. height; // number of rows in the current grid Dataset
Int dwidth = rasterprops. width; // Number of columns in the current raster Dataset
Double dx = rasterprops. meancellsize (). X; // The width of the grid.
Double DY = rasterprops. meancellsize (). Y; // The height of the grid.
Ienvelope extent = rasterprops. extent; // the range of the current raster Dataset
Rstpixeltype pixeltype = rasterprops. pixeltype; // The current grid pixel type.
Ipnt pntsize = new pntclass ();
Pntsize. setcoords (dx, Dy );
Ipixelblock pixelblock = clipraster. createpixelblock (pntsize );
Ipnt PNT = new pntclass ();
For (INT I = 0; I <dheight; I ++)
For (Int J = 0; j <dwidth; j ++)
{
PNT. setcoords (I, j );
Clipraster. Read (PNT, pixelblock );
If (pixelblock! = NULL)
{
Object OBJ = pixelblock. getval (0, 0, 0 );
MessageBox. Show (convert. touint32 (OBJ). tostring ());
}
}
6. How to extract raster data within a specified range
Two methods are commonly used to extract raster data within a specified range: irasterlayerexport (esricarto), iextractionop, iextractionop2 (esrispatialanalyst), and irasterlayerexport. The Raster Data Extraction function is limited, the range of a rectangle can only be used as the extraction range. The iextractionop interface provides polygon, circles, attributes, and rectangles to extract raster data.
1). irasterlayerexport Interface
Irasterlayerexport rlayerexport = new rasterlayerexportclass ();
Rlayerexport. rasterlayer = rasterlayer; // rasterlayer indicates the currently loaded raster layer.
Rlayerexport. extent = clipextent; // clipextent indicates the range of raster data extraction.
If (prospatialref! = NULL)
Rlayerexport. spatialreference = prospatialref; // projection information of the current Raster Data
Iworkspacefactory PWF = new rasterworkspacefactoryclass ();
Try
{
Iworkspace prasterworkspace = PWF. openfromfile (_ folder, 0); // _ folder indicates the storage path of the grid file.
Irasterdataset outgeodataset = rlayerexport. Export (prasterworkspace, code, strrastertype );
// Call the isaveas interface to save the exported Dataset
..........................
}
Catch (exception ex)
{
Throw new argumention (ex. Message );
}
2. iextractionop interface (check the space license before calling this interface)
Iextractionop extraction = new rasterextractionopclass ();
Try
{
Igeodataset geodataset = extraction. rectangle (igeodataset) clipraster, clipextent, true );
Iraster raster = geodataset as iraster;
If (raster! = NULL)
{
Iworkspacefactory WF = new rasterworkspacefactoryclass ();
Iworkspace rasterworkspace = WF. openfromfile (_ folder, 0 );
Isaveas saveas = (isaveas) raster;
Saveas. saveas ("result. tif", rasterworkspace, "tiff ");
}
}
Catch (exception ex)
{
MessageBox .. show (ex. Message );
}
7. resampling Raster Data
The resampling of raster data is mainly based on three methods: nearest and bilinear.
Ilinear) and cubic convolution (cubic ).
(1). Nearest Neighbor Sampling: it uses the nearest grid value in the input grid data as the output value. Therefore
Each raster value in the output raster is a real value in the input raster data without any change. This method is easy to use, with a small amount of computation and the fastest speed for re-sampling.
(2 ). bilinear Sampling: This method is used to take the four adjacent points around the points to be sampled (x, y), and interpolation is performed twice in the Y direction (or X direction, interpolation is performed in the X direction (or y direction) to obtain the grid value of the (x, y) Point.
(3) cubic convolution Sampling: This is a method to further improve the interpolation accuracy. Its basic idea is to add neighboring points for acquisition.
Obtain the best interpolation function. Take the adjacent 16 points around the point to be calculated, which is similar to Bilinear sampling. You can first insert data on one side up, for example, first in the X direction, and every four values are interpolated four times in sequence, then, based on the four calculation results, the interpolation result is obtained on the y side.
Sample Code: bilinear sampling
Irastergeometryproc rastergeometryproc = new rastergeometryprocclass ();
Rastergeometryproc. resample (rstresamplingtypes. rsp_cubicconvolution, newcellsize, clipraster );
This article from the GIS Space Station reprinted please in the form of a link to indicate the source URL: http://www.gissky.net/Article/1670.htm