public IRasterValue createRasterValue(IRasterDataset pRasterDs, IRasterStorageDef pRasStoreDef) { IRasterValue pRasterVal; pRasterVal = new RasterValueClass(); pRasterVal.RasterDataset = pRasterDs; pRasterVal.RasterStorageDef = pRasStoreDef; return(pRasterVal); // ++ cleanup //?问题,已经return后的语句是否能用? //pRasterVal = null; //pRasStoreDef = null; }
public void CreateSDERasterBaseOnFile(IRasterStorageDef pRasterStorage, string NewFileName, IRasterWorkspaceEx pRasterWSEx, string strRasterPath, string strRasterName) { //1、get original Raster IRasterDataset pRasterDataset = OpenRasterDataset(strRasterPath, strRasterName); //2、get the Raster's property IRaster pRaster = pRasterDataset.CreateDefaultRaster(); IRasterProps pRasterProp = pRaster as IRasterProps; rstPixelType pPixelType = pRasterProp.PixelType; //get the BandNumber of the Raster IRasterBandCollection pBands = pRasterDataset as IRasterBandCollection; int iBandNumber = pBands.Count; ISpatialReference pSR = pRasterProp.SpatialReference; Console.WriteLine("AAA"); IRasterDataset NewRaster = createSDERasterDs(pRasterWSEx, NewFileName, iBandNumber, pPixelType, pSR, pRasterStorage, null, ""); MosaicRasterToGDBRaster(pRasterDataset, NewRaster as IRasterDatasetEdit); }
private IRasterDataset CreateRasterDataset(ref IRasterDataset pRasterDataset, string name, ref IWorkspace pWorkspace, ISpatialReference pSpatialReference) { IRasterWorkspaceEx pRasterWorkspaceEx = (IRasterWorkspaceEx)pWorkspace; IRasterDataset newRasterDataset = null; IRaster pRaster = pRasterDataset.CreateDefaultRaster(); IRasterBandCollection pRasterBandCollection = (IRasterBandCollection)pRaster; int numbands = pRasterBandCollection.Count; IRasterProps pRasterProps = (IRasterProps)pRaster; rstPixelType pPixelType = pRasterProps.PixelType; IRasterStorageDef pRasterStorageDef = null; if (pRasterStorageDef == null) { pRasterStorageDef = new RasterStorageDefClass(); pRasterStorageDef.CompressionType = esriRasterCompressionType.esriRasterCompressionLZ77; pRasterStorageDef.PyramidLevel = 2; pRasterStorageDef.PyramidResampleType = rstResamplingTypes.RSP_BilinearInterpolation; pRasterStorageDef.TileHeight = 128; pRasterStorageDef.TileWidth = 128; } IRasterDef pRasterDef = new RasterDefClass(); pRasterDef.SpatialReference = pSpatialReference; pRasterDef.IsRasterDataset = true; pRasterDef.Description = "rasterdataset"; try { newRasterDataset = pRasterWorkspaceEx.CreateRasterDataset(name, numbands, pPixelType, pRasterStorageDef, "", pRasterDef, this.createGeometryDef(pSpatialReference)); return(newRasterDataset); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
public static IRasterDataset CreateSDERasterDs(IRasterWorkspaceEx irasterWorkspaceEx_0, string string_0, int int_0, rstPixelType rstPixelType_0, ISpatialReference ispatialReference_0, IRasterStorageDef irasterStorageDef_0, IRasterDef irasterDef_0, string string_1) { IRasterDataset dataset = null; IGeometryDef geometryDef = null; if (irasterDef_0 == null) { irasterDef_0 = CreateRasterDef(false, ispatialReference_0); } if (irasterStorageDef_0 == null) { irasterStorageDef_0 = CreateRasterStorageDef(); } geometryDef = CreateGeometryDef(irasterDef_0.SpatialReference); if (string_1.Length == 0) { string_1 = "DEFAULTS"; } try { dataset = irasterWorkspaceEx_0.CreateRasterDataset(string_0, int_0, rstPixelType_0, irasterStorageDef_0, string_1, irasterDef_0, geometryDef); } catch (COMException exception) { if (exception.ErrorCode == -2147155646) { MessageBox.Show("对象名 [" + string_0 + "] 不符合命名要求,请输入合适的对象名!"); return(dataset); } MessageBox.Show(exception.Message); } return(dataset); }
//************************Raster Load End*************************** //************************Raster Create Begin*********************** //函数编号:RasterCreate-01 //函数名:createSDERasterDs //函数功能:在给定的数据库中创建新的RasterDataset //参数: // rasterWorkspaceEx == destination geodatabase workspace (personal or ArcSDE) // rasterDatasetName == Name of raster dataset to create // numberOfBands == number of bands in the raster dataset that will be created // pixelType == type of pixel in target raster dataset // spatialReference == desired spatial reference in raster dataset // rasterStorageDef == RasterStorageDef object of Raster dataset -- defines pyramids, tiling, etc // rasterDef == definition for spatial reference // sKeyword == ArcSDE only, configuration keyword //备注: // 调用的函数:createGeometryDef(),createRasterStorageDef(),createRasterDef()等函数配合。 // Libraries: ESRI.ArcGIS.Geodatabase, ESRI.ArcGIS.Geometry public IRasterDataset createSDERasterDs(IRasterWorkspaceEx rasterWorkspaceEx, string rasterDatasetName, int numberOfBands, rstPixelType pixelType, ISpatialReference spatialReference, IRasterStorageDef rasterStorageDef, IRasterDef rasterDef, string keyword) { // Create a raster dataset in a geodatabase workspace IRasterDataset rasterDataset = null; IGeometryDef geometryDef; // if rasterdef is missing, create one with specified/unknown spatialreference if (rasterDef == null) { rasterDef = createRasterDef(false, spatialReference); } // if rasterstoragedef is missing, use default parameters if (rasterStorageDef == null) { rasterStorageDef = createRasterStorageDef(); } // create geometry definition geometryDef = createGeometryDef(spatialReference); // if keyword is missing, use default if (keyword.Length == 0) { keyword = "DEFAULTS"; } Console.WriteLine("bb"); rasterDataset = rasterWorkspaceEx.CreateRasterDataset(rasterDatasetName, numberOfBands, pixelType, rasterStorageDef, keyword, rasterDef, geometryDef); return(rasterDataset); }
/// <summary> /// 在Geodatabase中创建栅格数据集 /// </summary> /// <param name="pRasterWsEx">目标Geodatabase工作区</param> /// <param name="pDsName">栅格数据集名称</param> /// <param name="iNBannd">波段数</param> /// <param name="iPixeType">像素类型</param> /// <param name="pSpaRef">空间参考</param> /// <param name="pRasterStoreRef">存储栅格参数定义</param> /// <param name="pRasterDef">栅格空间参考定义</param> /// <param name="pKeyword"></param> /// <param name="eex"></param> /// <returns></returns> private IRasterDataset CreateRasterDataset(IRasterWorkspaceEx pRasterWsEx, string pDsName, int iNBannd, rstPixelType iPixeType, ISpatialReference pRasterSpaRef, ISpatialReference pGeoSpaRef, IRasterStorageDef pRasterStoreRef, IRasterDef pRasterDef, string pKeyword, out Exception eex) { eex = null; IRasterDataset pRasterDs = null; try { IGeometryDef pGeoDef = null; if (pRasterDef == null) { pRasterDef = CreateRasterDef(pRasterSpaRef); } if (pRasterStoreRef == null) { pRasterStoreRef = CreaterRasterStoreDef(); } pGeoDef = CreateGeoDef(pGeoSpaRef); if (pKeyword.Trim() == "") { pKeyword = "DEFAULTS"; } pRasterDs = pRasterWsEx.CreateRasterDataset(pDsName, iNBannd, iPixeType, pRasterStoreRef, pKeyword, pRasterDef, pGeoDef); } catch (Exception ex) { //******************************************************************* //guozheng added if (ModData.SysLog != null) { ModData.SysLog.Write(ex, null, DateTime.Now); } else { ModData.SysLog = new SysCommon.Log.clsWriteSystemFunctionLog(); ModData.SysLog.Write(ex, null, DateTime.Now); } //******************************************************************** eex = new Exception("创建栅格数据集出错!\n" + ex.Message); } return(pRasterDs); }
public IRasterDataset createSDERasterDs(IRasterWorkspaceEx irasterWorkspaceEx_0, string string_0, int int_0, rstPixelType rstPixelType_0, ISpatialReference ispatialReference_0, IRasterStorageDef irasterStorageDef_0, IRasterDef irasterDef_0, string string_1) { IRasterDataset rasterDataset = null; if (irasterDef_0 == null) { irasterDef_0 = this.method_0(false, ispatialReference_0); } if (irasterStorageDef_0 == null) { irasterStorageDef_0 = this.method_1(); } IGeometryDef geometryDef = this.method_2(ispatialReference_0); if (string_1.Length == 0) { string_1 = "DEFAULTS"; } rasterDataset = irasterWorkspaceEx_0.CreateRasterDataset(string_0, int_0, rstPixelType_0, irasterStorageDef_0, string_1, irasterDef_0, geometryDef); return(rasterDataset); }
public void RasDSToCatalogWithTime(IRasterDataset pRasterDs, IFeatureClass pCatalog, string DataField, string strData, IRasterStorageDef pRasStoreDef) { //IRasterCatalogItem pCatalogFeature; IFeatureCursor pCursor; IFeatureBuffer pRow; pCursor = pCatalog.Insert(false); IRasterCatalog pCat = pCatalog as IRasterCatalog; IDataset pDs; // loop through all the datasets and load if (pRasterDs != null) { pDs = pRasterDs as IDataset; pRow = pCatalog.CreateFeatureBuffer(); pRow.set_Value(pCat.RasterFieldIndex, createRasterValue(pRasterDs, pRasStoreDef)); pRow.set_Value(pCatalog.FindField(DataField), Convert.ToDateTime(strData)); pCursor.InsertFeature(pRow); } pRasterDs = null; }
//************************Raster Load End*************************** //************************Raster Create Begin*********************** //������ţ�RasterCreate-01 //��������createSDERasterDs //�������ܣ��ڸ��������ݿ��д����µ�RasterDataset //������ // rasterWorkspaceEx == destination geodatabase workspace (personal or ArcSDE) // rasterDatasetName == Name of raster dataset to create // numberOfBands == number of bands in the raster dataset that will be created // pixelType == type of pixel in target raster dataset // spatialReference == desired spatial reference in raster dataset // rasterStorageDef == RasterStorageDef object of Raster dataset -- defines pyramids, tiling, etc // rasterDef == definition for spatial reference // sKeyword == ArcSDE only, configuration keyword //��ע�� // ���õĺ�����createGeometryDef(),createRasterStorageDef()��createRasterDef()�Ⱥ�����ϡ� // Libraries: ESRI.ArcGIS.Geodatabase, ESRI.ArcGIS.Geometry public IRasterDataset createSDERasterDs(IRasterWorkspaceEx rasterWorkspaceEx, string rasterDatasetName, int numberOfBands, rstPixelType pixelType, ISpatialReference spatialReference, IRasterStorageDef rasterStorageDef, IRasterDef rasterDef, string keyword) { // Create a raster dataset in a geodatabase workspace IRasterDataset rasterDataset = null; IGeometryDef geometryDef; // if rasterdef is missing, create one with specified/unknown spatialreference if (rasterDef == null) rasterDef = createRasterDef(false, spatialReference); // if rasterstoragedef is missing, use default parameters if (rasterStorageDef == null) rasterStorageDef = createRasterStorageDef(); // create geometry definition geometryDef = createGeometryDef(spatialReference); // if keyword is missing, use default if (keyword.Length == 0) keyword = "DEFAULTS"; Console.WriteLine("bb"); rasterDataset = rasterWorkspaceEx.CreateRasterDataset(rasterDatasetName, numberOfBands, pixelType, rasterStorageDef, keyword, rasterDef, geometryDef); return rasterDataset; }
public void CreateSDERasterBaseOnFile(IRasterStorageDef pRasterStorage, string NewFileName, IRasterWorkspaceEx pRasterWSEx, string strRasterPath, string strRasterName) { //1��get original Raster IRasterDataset pRasterDataset = OpenRasterDataset(strRasterPath, strRasterName); //2��get the Raster's property IRaster pRaster = pRasterDataset.CreateDefaultRaster(); IRasterProps pRasterProp = pRaster as IRasterProps; rstPixelType pPixelType = pRasterProp.PixelType; //get the BandNumber of the Raster IRasterBandCollection pBands = pRasterDataset as IRasterBandCollection; int iBandNumber = pBands.Count; ISpatialReference pSR = pRasterProp.SpatialReference; Console.WriteLine("AAA"); IRasterDataset NewRaster = createSDERasterDs(pRasterWSEx, NewFileName, iBandNumber, pPixelType, pSR, pRasterStorage, null, ""); MosaicRasterToGDBRaster(pRasterDataset, NewRaster as IRasterDatasetEdit); }
public IRasterValue createRasterValue(IRasterDataset pRasterDs, IRasterStorageDef pRasStoreDef) { IRasterValue pRasterVal; pRasterVal = new RasterValueClass(); pRasterVal.RasterDataset = pRasterDs; pRasterVal.RasterStorageDef = pRasStoreDef; return (pRasterVal); // ++ cleanup //�����⣬�Ѿ�return�������Ƿ����ã� //pRasterVal = null; //pRasStoreDef = null; }