Exemplo n.º 1
0
        public bool CreateRaster(IRasterDataset pRDs, IRasterWorkspaceEx pWorkSpace)
        {
            IRasterProps      pRasterProps      = (IRasterProps)pRDs.CreateDefaultRaster();
            IRasterStorageDef pRasterStorageDef = new RasterStorageDefClass();

            pRasterStorageDef.CompressionType     = esriRasterCompressionType.esriRasterCompressionJPEG2000;
            pRasterStorageDef.CompressionQuality  = 50;
            pRasterStorageDef.PyramidLevel        = 2;
            pRasterStorageDef.PyramidResampleType = rstResamplingTypes.RSP_BilinearInterpolation;
            pRasterStorageDef.TileHeight          = 128;
            pRasterStorageDef.TileWidth           = 128;
            IRasterDef pRasterDef = new RasterDefClass();

            pRasterDef.Description      = "RasterDataset";
            pRasterDef.SpatialReference = pRasterProps.SpatialReference;
            IGeometryDef     pGeoDef     = new GeometryDefClass();
            IGeometryDefEdit pGeoDefEdit = pGeoDef as IGeometryDefEdit;

            pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            pGeoDefEdit.AvgNumPoints_2 = 4;
            pGeoDefEdit.GridCount_2    = 1;
            pGeoDefEdit.set_GridSize(0, 1000);
            pGeoDefEdit.SpatialReference_2 = pRasterProps.SpatialReference;
            IRasterDataset pRasterDataset = pWorkSpace.CreateRasterDataset("zzy", 3, rstPixelType.PT_UCHAR, pRasterStorageDef, "", pRasterDef, pGeoDef);

            pRasterDataset = pRDs;
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建栅格数据集
        /// </summary>
        /// <param name="pWorkspace"></param>
        /// <param name="sName"></param>
        /// <returns></returns>
        public IRasterDataset CreateRasterDataset(IWorkspace pWorkspace, string sName)
        {
            IRasterDataset rasterDataset = null;

            try
            {
                IRasterWorkspaceEx rasterWorkspace = pWorkspace as IRasterWorkspaceEx;
                rasterDataset = rasterWorkspace.CreateRasterDataset(sName, 3, rstPixelType.PT_CHAR, null, null, null, null);
            }
            catch (Exception ex)
            {
            }
            return(rasterDataset);
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        public void WriteToSDEFromPixelArray(IRasterWorkspaceEx irasterWorkspaceEx_0, string string_0)
        {
            IRasterDataset rasterDataset = irasterWorkspaceEx_0.CreateRasterDataset(string_0, 3, rstPixelType.PT_SHORT,
                                                                                    new RasterStorageDef(), "", new RasterDef(), null);
            IRaster      raster        = rasterDataset.CreateDefaultRaster();
            IRasterProps rasterProp    = raster as IRasterProps;
            int          num           = 1000;
            int          num1          = 1000;
            IEnvelope    envelopeClass = new Envelope()
            {
                XMin = 100,
                XMax = 500,
                YMin = 100,
                YMax = 500
            } as IEnvelope;

            rasterProp.Extent = envelopeClass;
            rasterProp.Width  = 1000;
            rasterProp.Height = 1000;
            IPnt pntClass = new Pnt();

            pntClass.SetCoords((double)1000, (double)1000);
            IPixelBlock3 pixelBlock3 = raster.CreatePixelBlock(pntClass) as IPixelBlock3;

            pntClass.SetCoords(0, 0);
            for (int i = 0; i < 3; i++)
            {
                object pixelData = pixelBlock3.PixelData[i];
                for (int j = 0; j < num; j++)
                {
                    int num2 = 0;
                    while (num2 < num1)
                    {
                        num2++;
                    }
                }
                pixelBlock3.PixelData[i] = pixelData;
            }
            (raster as IRasterEdit).Write(pntClass, pixelBlock3 as IPixelBlock);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        //************************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);
        }
Exemplo n.º 9
0
 public bool CreateRaster(IRasterDataset pRDs, IRasterWorkspaceEx pWorkSpace)
 {
     IRasterProps pRasterProps = (IRasterProps)pRDs.CreateDefaultRaster();
     IRasterStorageDef pRasterStorageDef = new RasterStorageDefClass();
     pRasterStorageDef.CompressionType = esriRasterCompressionType.esriRasterCompressionJPEG2000;
     pRasterStorageDef.CompressionQuality = 50;
     pRasterStorageDef.PyramidLevel = 2;
     pRasterStorageDef.PyramidResampleType = rstResamplingTypes.RSP_BilinearInterpolation;
     pRasterStorageDef.TileHeight = 128;
     pRasterStorageDef.TileWidth = 128;
     IRasterDef pRasterDef = new RasterDefClass();
     pRasterDef.Description = "RasterDataset";
     pRasterDef.SpatialReference = pRasterProps.SpatialReference;
     IGeometryDef pGeoDef = new GeometryDefClass();
     IGeometryDefEdit pGeoDefEdit = pGeoDef as IGeometryDefEdit;
     pGeoDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
     pGeoDefEdit.AvgNumPoints_2 = 4;
     pGeoDefEdit.GridCount_2 = 1;
     pGeoDefEdit.set_GridSize(0, 1000);
     pGeoDefEdit.SpatialReference_2 = pRasterProps.SpatialReference;
     IRasterDataset pRasterDataset = pWorkSpace.CreateRasterDataset("zzy", 3, rstPixelType.PT_UCHAR, pRasterStorageDef, "", pRasterDef, pGeoDef);
     pRasterDataset = pRDs;
     return true;
 }
Exemplo n.º 10
0
        //************************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;
        }
Exemplo n.º 11
0
        //创建数据集(矢量数据集和影像数据集)
        private void button2_Click(object sender, EventArgs e)
        {
            featureWorkspace = workspace as IFeatureWorkspace;
            rasterWorkspace  = workspace as IRasterWorkspaceEx;
            //定义空间参考
            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            ISpatialReference        spatialReference        = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_Beijing1954);

            spatialReference.SetDomain(-1000, -1000, 1000, 1000);

            IEnumDatasetName enumDatasetName;
            IDatasetName     datasetName;
            string           dsName = "";

            enumDatasetName = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
            datasetName     = enumDatasetName.Next();
            bool isExist = false;

            //创建矢量数据集
            dsName = "SDE." + this.textBox6.Text;
            while (datasetName != null)
            {
                if (datasetName.Name == dsName)
                {
                    isExist = true;
                }
                datasetName = enumDatasetName.Next();
            }
            if (isExist == false)
            {
                featureDataset = featureWorkspace.CreateFeatureDataset(this.textBox6.Text, spatialReference);
            }
            //创建影像数据集
            isExist         = false;
            enumDatasetName = workspace.get_DatasetNames(esriDatasetType.esriDTRasterDataset);
            datasetName     = enumDatasetName.Next();

            dsName = "SDE." + this.textBox6.Text;
            while (datasetName != null)
            {
                if (datasetName.Name == dsName)
                {
                    isExist = true;
                }
                datasetName = enumDatasetName.Next();
            }
            if (isExist == false)
            {
                //设置存储参数
                IRasterStorageDef rasterStorageDef = new RasterStorageDefClass();
                rasterStorageDef.CompressionType     = esriRasterCompressionType.esriRasterCompressionUncompressed;
                rasterStorageDef.PyramidLevel        = 1;
                rasterStorageDef.PyramidResampleType = rstResamplingTypes.RSP_BilinearInterpolation;
                rasterStorageDef.TileHeight          = 128;
                rasterStorageDef.TileWidth           = 128;
                //设置坐标系统
                IRasterDef        rasterDef             = new RasterDefClass();
                ISpatialReference rasterDpatialRefrence = new UnknownCoordinateSystemClass();
                rasterDef.SpatialReference = rasterDpatialRefrence;

                IGeometryDef     geometryDef     = new GeometryDefClass();
                IGeometryDefEdit geometryDefedit = (IGeometryDefEdit)geometryDef;
                geometryDefedit.AvgNumPoints_2 = 5;
                geometryDefedit.GridCount_2    = 1;
                geometryDefedit.set_GridSize(0, 1000);
                geometryDefedit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
                ISpatialReference spatialReference2 = new UnknownCoordinateSystemClass();
                geometryDefedit.SpatialReference_2 = spatialReference2;
                rasterDataset = rasterWorkspace.CreateRasterDataset(this.textBox7.Text, 1, rstPixelType.PT_LONG, rasterStorageDef, "DEFAULTS", rasterDef, geometryDef);
            }
        }