Exemplo n.º 1
0
        private IRasterDataset CopyRasterToWorkspace(IMap map, ILayer layer, IWorkspace wksDst, bool bLayerSpatial)
        {
            if (layer is IRasterLayer)
            {
                IRasterLayer rasterLayer = layer as IRasterLayer;
                if (rasterLayer.Raster == null)
                {
                    return(null);
                }

                IRaster rasterSrc = rasterLayer.Raster;
                //设置空间参考
                ISpatialReference spatialRef;
                if (bLayerSpatial)
                {
                    IGeoDataset pGeo = (IGeoDataset)rasterLayer;
                    spatialRef = pGeo.SpatialReference;
                }
                else
                {
                    spatialRef = map.SpatialReference;
                }

                ClsGDBDataCommon cls = new ClsGDBDataCommon();
                return(cls.ExportRasterToWorkspace(rasterSrc, wksDst, layer.Name, spatialRef));
            }
            return(null);
        }