久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

ArcEngine 柵格數(shù)據(jù) 總結(jié)

 山野村夫0lz056 2017-12-28

本文大部分內(nèi)容參考AO幫助文檔和ArcMap幫助文檔,大家實際使用中遇到的問題也可以在本帖下方留言交流,,謝謝,!
歡迎瀏覽,拒絕轉(zhuǎn)載,!

基礎(chǔ)知識

柵格數(shù)據(jù)基礎(chǔ)知識:傳送門

柵格數(shù)據(jù)是由一系列等間距的格網(wǎng)矩陣組成,,用來表達完整的主題、光譜,、圖像信息,。
柵格數(shù)據(jù)模型分為柵格數(shù)據(jù)集(Raster dataset),、柵格目錄(Raster catalog)、鑲嵌數(shù)據(jù)集(Mosaic dataset),。他們以文件系統(tǒng),、個人地理數(shù)據(jù)庫、文件地理數(shù)據(jù)庫,、企業(yè)地理數(shù)據(jù)庫為數(shù)據(jù)源進行存儲,。

柵格數(shù)據(jù)集也就是我們經(jīng)常所得的jpg、tif文件等,, ArcGIS 將這些柵格數(shù)據(jù)抽象為 RasterDataset,,柵格數(shù)據(jù)集就代表了磁盤中的一個文件,它由一個或多個波段組成,。在使用柵格數(shù)據(jù)集的時候,,柵格數(shù)據(jù)會被轉(zhuǎn)換成 IMG 文件存儲在數(shù)據(jù)庫中。我們可以對柵格數(shù)據(jù)集進行一些操作,,如改變空間參考,,建立影像金字塔等。

柵格目錄,,正如其名字一樣是一個目錄,,跟書的目錄相似,它記錄了一個或者多個柵格數(shù)據(jù)集,,每一個柵格數(shù)據(jù)集都作為一條記錄存儲在柵格目錄中,。柵格目錄對柵格數(shù)據(jù)集的管理有兩種方式,托管和非托管,。托管方式的時候,,柵格數(shù)據(jù)是存儲在數(shù)據(jù)庫中, 非托管的時候,,柵格目錄記錄了柵格數(shù)據(jù)集的路徑,,也就是柵格數(shù)據(jù)并沒有存儲在數(shù)據(jù)庫中。當(dāng)我們刪除一條記錄的時候,,對我們的柵格數(shù)據(jù)沒有任何影響,。

鑲嵌數(shù)據(jù)集可以說是柵格數(shù)據(jù)集和柵格目錄的混合技術(shù),它的存儲方式和柵格目錄類似,,但是在使用的時候和普通的柵格數(shù)據(jù)集是一樣的,,鑲嵌數(shù)據(jù)集用于管理和發(fā)布海量多分辨率,多傳感器影像,,對柵格數(shù)據(jù)提供了動態(tài)鑲嵌和實時處理的功能,。
對文件地理數(shù)據(jù)庫、個人地理數(shù)據(jù)庫和 ArcSDE 地理數(shù)據(jù)庫中的柵格存儲加以比較:
這里寫圖片描述

類圖

在線地址:傳送門
本地路徑:本地路徑:如 C:\Program Files (x86)\ArcGIS\DeveloperKit10.2\Diagrams\DataSourcesRasterObjectModel.pdf

和柵格數(shù)據(jù)集有關(guān)的GP工具

這里寫圖片描述

柵格數(shù)據(jù)接口使用示例

這里寫圖片描述

打開柵格數(shù)據(jù)工作空間

//Open a file geodatabase workspace as RasterWorkspace.static IRasterWorkspaceEx OpenFGDB(string FGDBPath){ //FGDBPath string example: c:\data\raster.gdb. IWorkspaceFactory2 workspaceFactory = new FileGDBWorkspaceFactoryClass(); return (IRasterWorkspaceEx)workspaceFactory.OpenFromFile(FGDBPath, 0);}//Open an ArcSDE workspace as RasterWorkspace.static IRasterWorkspaceEx OpenSDE(string conString){ //conString example: SERVER=ais;INSTANCE=9200;VERSION=sde.DEFAULT;USER=raster;PASSWORD=raster. IWorkspaceFactory2 workspaceFactory = new SdeWorkspaceFactoryClass(); return (IRasterWorkspaceEx)workspaceFactory.OpenFromString(conString, 0);}//Open an accessed workspace as RasterWorkspace.static IRasterWorkspaceEx OpenAccess(string PGDBPath){ //FGDBPath string example: c:\data\rasters.mdb. IWorkspaceFactory2 workspaceFactory = new AccessWorkspaceFactoryClass(); return (IRasterWorkspaceEx)workspaceFactory.OpenFromFile(PGDBPath, 0);}//Open a file workspace as RasterWorkspace.static IRasterWorkspace OpenFileWorkspace(string wsPath){ //wsPath example: c:\data\rasters. IWorkspaceFactory workspaceFact = new RasterWorkspaceFactoryClass(); return (IRasterWorkspace)workspaceFact.OpenFromFile(wsPath, 0);}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

打開柵格數(shù)據(jù)集

IRasterDataset rasterDataset = rasterWorkspace.OpenRasterDataset(datasetName);
  • 1
IRasterDataset rasterDataset = rasterWorkspaceEx.OpenRasterDataset(datasetName);
  • 1

創(chuàng)建柵格數(shù)據(jù)集

  1. Creating a raster dataset(創(chuàng)建以文件存儲的柵格數(shù)據(jù)集,如TIFF)
    1)Create a workspace.創(chuàng)建工作空間
    2)Create a TIFF file with specified width, height, pixel type, cell size, and other necessary dimensions.創(chuàng)建一個TIFF文件,,并指定它的寬度,高度,像素類型,、像元大小和其他必要的維度。
    3)Use the IPixelBlock and IRasterEdit interfaces to edit the pixel values.使用IPixelBlock 和 IRasterEdit 接口來編輯像元的值,。
public static IRasterDataset CreateRasterDataset(string Path, string FileName){ try { IRasterWorkspace2 rasterWs = OpenRasterWorkspace(Path); //Define the spatial reference of the raster dataset. ISpatialReference sr = new UnknownCoordinateSystemClass(); //Define the origin for the raster dataset, which is the lower left corner of the raster. IPoint origin = new PointClass(); origin.PutCoords(15.0, 15.0); //Define the dimensions of the raster dataset. int width = 100; //This is the width of the raster dataset. int height = 100; //This is the height of the raster dataset. double xCell = 30; //This is the cell size in x direction. double yCell = 30; //This is the cell size in y direction. int NumBand = 1; // This is the number of bands the raster dataset contains. //Create a raster dataset in TIFF format. IRasterDataset rasterDataset = rasterWs.CreateRasterDataset(FileName, 'TIFF', origin, width, height, xCell, yCell, NumBand, rstPixelType.PT_UCHAR, sr, true); //If you need to set NoData for some of the pixels, you need to set it on band //to get the raster band. IRasterBandCollection rasterBands = (IRasterBandCollection)rasterDataset; IRasterBand rasterBand; IRasterProps rasterProps; rasterBand = rasterBands.Item(0); rasterProps = (IRasterProps)rasterBand; //Set NoData if necessary. For a multiband image, a NoData value needs to be set for each band. rasterProps.NoDataValue = 255; //Create a raster from the dataset. IRaster raster = rasterDataset.CreateFullRaster(); //Create a pixel block using the weight and height of the raster dataset. //If the raster dataset is large, a smaller pixel block should be used. //Refer to the topic 'How to access pixel data using a raster cursor'. IPnt blocksize = new PntClass(); blocksize.SetCoords(width, height); IPixelBlock3 pixelblock = raster.CreatePixelBlock(blocksize)as IPixelBlock3; //Populate some pixel values to the pixel block. System.Array pixels; pixels = (System.Array)pixelblock.get_PixelData(0); for (int i = 0; i < width;="" i++)="">for (int j = 0; j < height;="" j++)="">if (i == j) pixels.SetValue(Convert.ToByte(255), i, j); else pixels.SetValue(Convert.ToByte((i * j) / 255), i, j); pixelblock.set_PixelData(0, (System.Array)pixels); //Define the location that the upper left corner of the pixel block is to write. IPnt upperLeft = new PntClass(); upperLeft.SetCoords(0, 0); //Write the pixel block. IRasterEdit rasterEdit = (IRasterEdit)raster; rasterEdit.Write(upperLeft, (IPixelBlock)pixelblock); //Release rasterEdit explicitly. System.Runtime.InteropServices.Marshal.ReleaseComObject(rasterEdit); return rasterDataset; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return null; }}public static IRasterWorkspace2 OpenRasterWorkspace(string PathName){ //This function opens a raster workspace. try { IWorkspaceFactory workspaceFact = new RasterWorkspaceFactoryClass(); return workspaceFact.OpenFromFile(PathName, 0)as IRasterWorkspace2; } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); return null; }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  1. Creating a raster dataset in a geodatabase(創(chuàng)建以GDB存儲的柵格數(shù)據(jù)集,,如GRID)
    1)Create a file geodatabase workspace factory.創(chuàng)建哥FGDB的工作工廠對象。
    2)Create a raster workspace and query IRasterWorkspaceEx.創(chuàng)建一個柵格工作空間對象并且轉(zhuǎn)換到IRasterWorkspaceEx對象上
    3)Define the storage and raster properties using the RasterStorageDef and RasterDef classes. 利用RasterStorageDef 和RasterDef 類定義柵格數(shù)據(jù)集的存儲和柵格屬性,。
    4)Create the dataset using the CreateRasterDataset method.利用CreateRasterDataset方法創(chuàng)建柵格數(shù)據(jù)集,。
IWorkspaceFactory wsf = new FileGDBWorkspaceFactoryClass();IRasterWorkspaceEx ws = (IRasterWorkspaceEx)wsf.OpenFromFile(@'c:\temp\fgdb.gdb', 0);//Define the raster storage.IRasterStorageDef storage = new RasterStorageDefClass();storage.Tiled = true;storage.TileHeight = 128;storage.TileWidth = 128;//Define the spatial reference.IRasterDef rasterDef = new RasterDefClass();rasterDef.SpatialReference = new UnknownCoordinateSystemClass();//Create data.IRasterDataset rasterDs = ws.CreateRasterDataset('newraster', 3,rstPixelType.PT_SHORT, storage, 'sde.DEFAULT', rasterDef, null);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

訪問HDF和NIFF數(shù)據(jù)的子集

一些柵格格式,如分層數(shù)據(jù)格式(HDF),可以在單個文件中包含多個subdatasets。訪問HDF subdatasets使用IRasterDatasetJukebox接口,請參見下面的代碼示例:

IWorkspaceFactory wsf = new FileGDBWorkspaceFactoryClass();IRasterWorkspaceEx ws = (IRasterWorkspaceEx)wsf.OpenFromFile(@'c:\temp\fgdb.gdb', 0);//Define the raster storage.IRasterStorageDef storage = new RasterStorageDefClass();storage.Tiled = true;storage.TileHeight = 128;storage.TileWidth = 128;//Define the spatial reference.IRasterDef rasterDef = new RasterDefClass();rasterDef.SpatialReference = new UnknownCoordinateSystemClass();//Create data.IRasterDataset rasterDs = ws.CreateRasterDataset('newraster', 3,rstPixelType.PT_SHORT, storage, 'sde.DEFAULT', rasterDef, null);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

讀取JPEG EXIF擴展標記信息

public static void JPEG_EXIFtag(IRasterDataset exifDataset){ //exifDataset represents a raster dataset opened from a JPEG file that has EXIF tags. IDataset dataset = (IDataset)exifDataset; //Get the EXIF tags and the associated values. IPropertySet propertySet = dataset.PropertySet; System.Object tag_names; System.Object tag_values; propertySet.GetAllProperties(out tag_names, out tag_values); string[] stringNames = (string[])tag_names; object[] stringValues = (object[])tag_values; for (int i = 0; i < stringnames.length="" -="">1; i++) { System.Console.WriteLine(stringNames[i]); System.Console.WriteLine(stringValues[i]); }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

讀取像素數(shù)據(jù)

  • 使用光柵游標訪問像素數(shù)據(jù)
public static void UsingRasterCursorWithPixelBlock(IRasterDataset2 rasterDs){ try { //Create a raster. IRaster2 raster2 = rasterDs.CreateFullRaster()as IRaster2; //Create a raster cursor with a system-optimized pixel block size by passing a null. IRasterCursor rasterCursor = raster2.CreateCursorEx(null); //Use the IRasterEdit interface. IRasterEdit rasterEdit = raster2 as IRasterEdit; //Loop through each band and pixel block. IRasterBandCollection bands = rasterDs as IRasterBandCollection; IPixelBlock3 pixelblock3 = null; long blockwidth = 0; long blockheight = 0; System.Array pixels; IPnt tlc = null; object v; long bandCount = bands.Count; do { pixelblock3 = rasterCursor.PixelBlock as IPixelBlock3; blockwidth = pixelblock3.Width; blockheight = pixelblock3.Height; pixelblock3.Mask(255); for (int k = 0; k < bandcount;="" k++)="" {="">//Get the pixel array. pixels = (System.Array)pixelblock3.get_PixelData(k); for (long i = 0; i < blockwidth;="" i++)="" {="">for (long j = 0; j < blockheight;="" j++)="" {="">//Get the pixel value. v = pixels.GetValue(i, j); //Do something with the value. } } //Set the pixel array to the pixel block. pixelblock3.set_PixelData(k, pixels); } //Write back to the raster. tlc = rasterCursor.TopLeft; rasterEdit.Write(tlc, (IPixelBlock)pixelblock3); } while (rasterCursor.Next() == true); System.Runtime.InteropServices.Marshal.ReleaseComObject(rasterEdit); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 使用RawBlocks 對象訪問像素數(shù)據(jù)
    Raster pixels can be accessed through the IRasterEdit and IPixelBlock3 interfaces. These interfaces read and edit pixels on raster objects. The RawBlocks object, new at ArcGIS 10, works with pixels on a raster band. It reads pixels using an internal tiling structure and loops through the pixel blocks without resampling.
    This topic shows how to use the RawBlocks object to manipulate raster data at a pixel level.
    概要翻譯:可以通過IRasterEdit 和 IPixelBlock3 接口訪問柵格像素,,這兩個接口會在柵格對象本身讀去和編輯柵格像素,。在ArcGIS10版本以后,提供了使用RawBlocks 對象,,它在柵格波段上操作像素,,它使用一個內(nèi)部瓦片結(jié)構(gòu)和循環(huán)遍歷像素塊(沒有重采樣)讀取像素。這一主題展示了如何使用RawBlocks對象在一個像素水平操縱柵格數(shù)據(jù),。
public static void ReadWriteRawBlocks(IRasterDataset rasDs){ IRasterBandCollection rasBandCol = (IRasterBandCollection)rasDs; IRawBlocks rawBlocks; IRasterInfo rasInfo; IPixelBlock pb; // Iterate through each band of the dataset. for (int m = 0; m <= rasbandcol.count="" -="" 1;=""> { // QI to IRawBlocks from IRasterBandCollection. rawBlocks = (IRawBlocks)rasBandCol.Item(m); rasInfo = rawBlocks.RasterInfo; // Create the pixel block. pb = rawBlocks.CreatePixelBlock(); // Determine the tiling scheme for the raster dataset. int bStartX = (int)Math.Floor((rasInfo.Extent.Envelope.XMin - rasInfo.Origin.X) / (rasInfo.BlockWidth * rasInfo.CellSize.X)); int bEndX = (int)Math.Ceiling((rasInfo.Extent.Envelope.XMax - rasInfo.Origin.X) / (rasInfo.BlockWidth * rasInfo.CellSize.X)); int bStartY = (int)Math.Floor((rasInfo.Origin.Y - rasInfo.Extent.Envelope.YMax) / (rasInfo.BlockHeight * rasInfo.CellSize.Y)); int bEndY = (int)Math.Ceiling((rasInfo.Origin.Y - rasInfo.Extent.Envelope.YMin) / (rasInfo.BlockHeight * rasInfo.CellSize.Y)); // Iterate through the pixel blocks. for (int pbYcursor = startY; pbYcursor < endy;=""> { for (int pbXcursor = startX; pbXcursor < endx;=""> { // Get the pixel block. rawBlocks.ReadBlock(pbXcursor, pbYcursor, 0, pb); System.Array safeArray; // Put the pixel block into a SafeArray for manipulation. safeArray = (System.Array)pb.get_SafeArray(0); // Iterate through the pixels in the pixel block. for (int safeArrayHeight = 0; safeArrayHeight <> safeArrayHeight++) { for (int safeArrayWidth = 0; safeArrayWidth <> safeArrayWidth++) { // Use System.Array.SetValue to write the new pixel value back into the SafeArray. safeArray.SetValue(Convert.ToByte(128), safeArrayWidth, safeArrayHeight); } } // Set the SafeArray back to the pixel block. pb.set_SafeArray(0, safeArray); // Write the pixel block back to the dataset. rawBlocks.WriteBlock(pbXcursor, pbYcursor, 0, pb); } } }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61

創(chuàng)建柵格屬性表

static void BuildRasterAttributeTable(IRasterDataset rasterDataset, ITable table){ //Cast to IRasterDatasetEdit2 to build a raster attribute table. IRasterDatasetEdit2 rasterDatasetEdit = (IRasterDatasetEdit2)rasterDataset; //Build a default raster attribute table with VALUE and COUNT fields. if (table == null) { rasterDatasetEdit.BuildAttributeTable(); } else { //Assign the given table as the raster attribute table. rasterDatasetEdit.AlterAttributeTable(table); }}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

讀取柵格數(shù)據(jù)屬性(官方文檔)

這里寫圖片描述

主要用到的接口:
1) IRasterProps
2) IRasterBandCollection
3) IRasterDataset
4) IRasterPyramid3
5) IRasterBand
柵格屬性列表:
列數(shù)和行數(shù)(Columns and Rows):通過IRasterProps的Width和Height屬性獲取
波段數(shù)量(Number of Bands):通過IRasterBandCollection接口獲取(可以由IRaster對象跳轉(zhuǎn)接口到此接口)
像元大小(CellSize(X,,Y)):通過IRasterProps的MeanCellSize
格式(Format):通過IRasterDataset的Format屬性獲取
源類型(Source Type):可以通過GP工具SetRasterProperties來設(shè)置。
像素類型(Pixel Type):通過IRasterProps接口的PixelType 屬性獲取
像素位深(Pixel Depth):根據(jù)像素類型來判斷像素位深
無數(shù)據(jù)值(NoData Value):通過IRasterProps 的NoDataValue屬性獲取
顏色表/色帶(Colormap):通過IRaster2接口的Colormap屬性獲取色帶
金字塔(Pyramids):通過IRasterPyramid3接口來創(chuàng)建,、獲取,、刪除金字塔(PS:用IRasterDataset接口跳轉(zhuǎn)到IRasterPyramid3接口)
壓縮(Compression):通過IRasterDataset的CompressionType屬性獲取壓縮類型
范圍(Extent):將IRasterDataset接口對象轉(zhuǎn)換成IGeoDataset對象來范圍信息
空間參考(Spatial Reference):1)將IRasterDataset接口對象轉(zhuǎn)換成IGeoDataset對象來獲取空間參考信息 2)通過IRasterProps 的屬性SpatialReference獲取 3)其它方法
統(tǒng)計(Statistics):通過IRasterBand接口的Statistics屬性獲取波段的統(tǒng)計信息
波段集合:通過IRasterBandCollection 接口來添加,、刪除,、獲取波段。

構(gòu)建金字塔

構(gòu)建金字塔有兩種方式:1)利用IRasterPyramid3接口來創(chuàng)建金字塔 2)利用GP工具創(chuàng)建金字塔
示例代碼:
1)

IRasterPyramid3 pRasterPyramid = rasterDataset as IRasterPyramid3;if (pRasterPyramid != null && !pRasterPyramid.Present){ //-1代表創(chuàng)建全部級別的金字塔,,0代表刪除金字塔,,其它代表創(chuàng)建對應(yīng)級別的金字塔 pRasterPyramid.BuildPyramid(-1, rstResamplingTypes.RSP_NearestNeighbor);}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

2)
這里寫圖片描述

//如何監(jiān)聽GP消息請參考文章《ArcEngine GP筆記(持續(xù)補充中......)》ESRI.ArcGIS.DataManagementTools.BuildPyramids buildPyramids = new ESRI.ArcGIS.DataManagementTools.BuildPyramids();buildPyramids.in_raster_dataset = sRasterFile; //柵格數(shù)據(jù)源buildPyramids.resample_technique = cmbEditResample.Text; //重分類方法buildPyramids.compression_type = cmbEditCompressType.Text; //壓縮類型buildPyramids.compression_quality = Convert.ToInt32(txtCompressQuality.Text); //壓縮質(zhì)量IGeoProcessorResult gpResult = m_geoProcesser.Execute(buildPyramids, null);if (gpResult.Status == ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded){ //do something }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

個人經(jīng)驗:遇到數(shù)據(jù)量大的數(shù)據(jù)創(chuàng)建金字塔比較耗時,建議使用第二種方式GP工具創(chuàng)建金字塔,,可以對GP工具進行監(jiān)聽,,實時輸出動態(tài)消息;數(shù)據(jù)量小的時候可以使用接口,,簡單快捷,。個人經(jīng)驗僅供參考,如有意見,,請留言,!

柵格數(shù)據(jù)另存

柵格數(shù)據(jù)另存有兩種方式:1)一種利用ISaveAs和ISaveAs2接口 2)利用GP工具另存
示例代碼:
1)

ISaveAs2 pSaveAs = pSaster as ISaveAs2;if (!pSaveAs.CanSaveAs(sFormat)){ XtraMessageBox.Show('不支持指定像素類型或文件格式的輸出', '提示', MessageBoxButtons.OK, MessageBoxIcon.Information); return ;}IWorkspaceFactory worksapceFactory = new RasterWorkspaceFactoryClass();workspace = worksapceFactory.OpenFromFile(System.IO.Path.GetDirectoryName(m_sOutputPath), 0);IDataset dataset = pSaveAs.SaveAs(System.IO.Path.GetFileName(m_sOutputPath), workspace, sFormat);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

2)
可以利用CopyRaster工具拷貝一份柵格數(shù)據(jù)實現(xiàn)柵格數(shù)據(jù)的另存。
個人經(jīng)驗: ISaveAs 保存Grid格式數(shù)據(jù)技巧

柵格數(shù)據(jù)裁切

柵格數(shù)據(jù)裁切有兩種方式:1)利用接口進行裁切 2)利用GP工具進行裁切
1)
①基于IEnvelope對象裁切,,主要用到的接口:IRasterGeometryProc

IRasterGeometryProc pRasterGeometryProc = new RasterGeometryProcClass();pRasterGeometryProc.Clip(pClipEnvelope,pInputRaster)
  • 1
  • 2

②利用 IExtractionOp2接口進行裁切,,然后用ISaveAs2接口保存裁切后的結(jié)果。代碼鏈接:傳送門
③ 其它可能的方法
2)
調(diào)用Clip工具進行裁切,代碼略(這塊我做過基于范圍,、文件,、ROI繪制圖形的裁切,不會的可以留言,,我可以把示例代碼發(fā)過去),。
這塊有幾個注意事項:
① 注意輸入數(shù)據(jù)和裁切范圍要有坐標系
② 注意被裁切的數(shù)據(jù)和裁切范圍是否可以疊加上
③ 注意將裁切范圍轉(zhuǎn)換到輸入數(shù)據(jù)的坐標系上去
④ 如果基于柵格文件裁切,clipping_geometry設(shè)置為 “NONE”,;如果基于矢量文件裁切,,clipping_geometry設(shè)置為 “ClippingGeometry”;
⑤ 如果基于四角坐標裁切,,注意rectangle參數(shù)格式;如果in_template_dataset不為空字符串或空對象,,設(shè)置rectangle參數(shù)為“#”即可。

in_rectangle = string.Format('{0} {1} {2} {3}', pEnvelope.XMin, pEnvelope.YMin, pEnvelope.XMax, pEnvelope.YMax);
  • 1

柵格數(shù)據(jù)可視化

1.柵格數(shù)據(jù)渲染包括一下幾種:
- Raster Unique value Renderer 唯一值渲染
- Raster Classify Renderer 分類渲染
- Raster Stretch Renderer 色帶拉伸渲染
- RGB渲染,,必須為多波段影像
主要用到的接口:
1) IRasterLayer
2) IRasterRenderer

這里寫圖片描述
示例代碼暫時略,,有問題的同學(xué)可以留言。這塊想著以后有時間的話以新帖子總結(jié),,順便將色帶總結(jié)了,。

2.柵格圖層的顯示效果
柵格圖層的顯示效果受亮度、對比度,、透明度等因素的影響,。
用到的接口:
1)ILayerEffects
2)IRasterDisplayProps

柵格數(shù)據(jù)分析

分享幾個我項目中用到的柵格分析功能的例子:
1)坡度分析

private IRaster ProduceSlopeData(DirectoryInfo demFile, string outputFolder, string strOutputMeasurement, double zFactor, IGeoDataset inputGeoDataset, IWorkspace pWorkspace){ IRaster solpeRaster = null; ISurfaceOp pSurface = new RasterSurfaceOpClass(); esriGeoAnalysisSlopeEnum enumSlope = (strOutputMeasurement == 'DEGREE') ? esriGeoAnalysisSlopeEnum.esriGeoAnalysisSlopeDegrees : esriGeoAnalysisSlopeEnum.esriGeoAnalysisSlopePercentrise; IGeoDataset outSlopeDataset = pSurface.Slope(inputGeoDataset, enumSlope, zFactor); //輸出坡度數(shù)據(jù) ISaveAs pSlopeSaveAs = outSlopeDataset as ISaveAs; string outputSlopeName = demFile.Parent.Name.ToUpper() +'SLP'; //string outputSlopeName = demFile.Parent.Name + 'SLP.tif'; if (System.IO.File.Exists(System.IO.Path.Combine(outputFolder, outputSlopeName))) { IRasterDataset oldRasterDataset = (pWorkspace as IRasterWorkspace).OpenRasterDataset(outputSlopeName); (oldRasterDataset as IDataset).Delete(); } IDataset solpeDataset = pSlopeSaveAs.SaveAs(outputSlopeName, pWorkspace, 'GRID'); //IDataset solpeDataset = pSlopeSaveAs.SaveAs(outputSlopeName, pWorkspace, 'TIFF'); IRasterDataset solpeRasterDataset = solpeDataset as IRasterDataset; if (solpeRasterDataset != null) { solpeRaster = solpeRasterDataset.CreateDefaultRaster(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(outSlopeDataset); System.Runtime.InteropServices.Marshal.ReleaseComObject(solpeRasterDataset); return solpeRaster;}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32

2)坡向分析

private void ProduceAspectData(DirectoryInfo demFile, string outputFolder, IGeoDataset inputGeoDataset, IWorkspace pWorkspace){ ISurfaceOp pSurface = new RasterSurfaceOpClass(); IGeoDataset outAspectDataset = pSurface.Aspect(inputGeoDataset); ISaveAs pAspectSaveAs = outAspectDataset as ISaveAs; string outputAspectName = demFile.Parent.Name.ToUpper() + 'SPD'; //string outputAspectName = demFile.Parent.Name + 'SPD.tif'; string outputAspectFilePath = System.IO.Path.Combine(outputFolder, outputAspectName); if (System.IO.File.Exists(outputAspectFilePath)) { IRasterDataset oldRasterDataset = (pWorkspace as IRasterWorkspace).OpenRasterDataset(outputAspectName); (oldRasterDataset as IDataset).Delete(); } IDataset aspectDataset = pAspectSaveAs.SaveAs(outputAspectName, pWorkspace, 'GRID'); //IDataset aspectDataset = pAspectSaveAs.SaveAs(outputAspectName, pWorkspace, 'TIFF'); System.Runtime.InteropServices.Marshal.ReleaseComObject(outAspectDataset); System.Runtime.InteropServices.Marshal.ReleaseComObject(aspectDataset);}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

3)重分類

private IRasterDataset ProduceSlopeZone(DirectoryInfo demFile, string outputFolder, IWorkspace pWorkspace, IRaster pInRaster){ if (pInRaster == null) { m_richTxtBoxLog.SelectionColor = System.Drawing.Color.Red; m_richTxtBoxLog.AppendText('生成高程帶數(shù)據(jù)失敗,!\r\n'); return null; } IReclassOp pReclassOp = new RasterReclassOpClass(); IGeoDataset pGeodataset = pInRaster as IGeoDataset; INumberRemap pNumRemap = new NumberRemapClass(); IRasterStatistics pRasterStatistic = GetRasterStatistics(pInRaster); pNumRemap.MapRange(0, 2, 0); pNumRemap.MapRange(2, 3, 2); pNumRemap.MapRange(3, 5, 3); pNumRemap.MapRange(5, 6, 5); pNumRemap.MapRange(6, 8, 6); pNumRemap.MapRange(8, 10, 8); pNumRemap.MapRange(10, 15, 10); pNumRemap.MapRange(15, 25, 15); pNumRemap.MapRange(25, 35, 25); pNumRemap.MapRange(35, 45, 35); if (pRasterStatistic.Maximum > 45) { pNumRemap.MapRange(45, 90, 45); } IRemap pRemap = pNumRemap as IRemap; IRaster2 pOutRaster = pReclassOp.ReclassByRemap(pGeodataset, pRemap, false) as IRaster2; //保存 ISaveAs pAspectSaveAs = pOutRaster as ISaveAs; string outputAspectName = demFile.Parent.Name.ToUpper() + 'SPZA.tif'; if (System.IO.File.Exists(System.IO.Path.Combine(outputFolder, outputAspectName))) { IRasterDataset oldRasterDataset = (pWorkspace as IRasterWorkspace).OpenRasterDataset(outputAspectName); (oldRasterDataset as IDataset).Delete(); } IDataset aspectDataset = pAspectSaveAs.SaveAs(outputAspectName, pWorkspace, 'TIFF'); System.Runtime.InteropServices.Marshal.ReleaseComObject(pInRaster); return (aspectDataset as IRasterDataset); }/// /// 獲取柵格統(tǒng)計/// /// /// private IRasterStatistics GetRasterStatistics(IRaster pRaster){ if (null == pRaster) return null; IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection; IRasterBand pRBand = pRBandCol.Item(0); if (pRBand.Statistics == null) { pRBand.ComputeStatsAndHist(); } return pRBand.Statistics;}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60

和柵格數(shù)據(jù)相關(guān)的GP工具箱

和柵格數(shù)據(jù)有關(guān)的工具箱:3D Analyst Tools ,、Data Management Tools、Spatial Analyst Tools 等工具箱,。

具體內(nèi)容不在此贅述,,有問題的可以留言。

本文書寫參考內(nèi)容:
1)官方幫助文檔
2)個人項目經(jīng)驗
3)參考博客:arcengine柵格數(shù)據(jù)使用總結(jié)
4)相關(guān)文檔資料:CSDN下載-》ArcEngine 柵格數(shù)據(jù)總結(jié).ppt

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多