GIS的积累
It is never to late to learn

导航

 

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using ESRI.ArcGIS.Geoprocessor;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geoprocessing;
using ESRI.ArcGIS.AnalysisTools;

using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesRaster;
using ESRI.ArcGIS.SpatialAnalystTools;

 

 

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //构造Geoprocessor
            ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            //设置参数
            ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
            intersect.in_features = @"E:\数据\temp\New_Shapefile.shp;E:\数据\temp\New_Shapefile_Intersect.shp";
            intersect.out_feature_class = @"E:\数据\temp\intersectOne.shp";
            intersect.join_attributes = "ONLY_FID";
            //执行Intersect工具
            RunTool(gp, intersect, null);

           

 

        }

        private void RunTool(Geoprocessor geoprocessor, IGPProcess process, ITrackCancel TC)
        {
            // Set the overwrite output option to true
            geoprocessor.OverwriteOutput = true;

            try
            {
                geoprocessor.Execute(process, null);
                ReturnMessages(geoprocessor);

            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                ReturnMessages(geoprocessor);
            }
         
        }


    
         // Function for returning the tool messages.
        private void ReturnMessages(Geoprocessor gp)
        {
            string ms = "";
            if (gp.MessageCount > 0)
            {
                for (int Count = 0; Count <= gp.MessageCount - 1; Count++)
                {
                    ms += gp.GetMessage(Count);
                }
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            //构造Geoprocessor
            //遍历得到所有N开头的Featureclass
            ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            gp.SetEnvironmentValue("workspace",@"E:\数据\temp");
            IGpEnumList featureClasses = gp.ListFeatureClasses("N*", "", "");
            String featureClass = featureClasses.Next();
            while (featureClass != "")
            {
                Console.WriteLine(featureClass.ToString());
                featureClass = featureClasses.Next();
            }
            MessageBox.Show("Done!");

        }

        private void button4_Click(object sender, EventArgs e)
        {
            // List all TIF files in the workspace and build pyramids
            ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            gp.SetEnvironmentValue("workspace", @"E:\数据\temp");
            IGpEnumList rasters = gp.ListRasters("", "img");
            String raster = rasters.Next();
            while (raster != "")
            {
                Console.WriteLine(raster.ToString());
                raster = rasters.Next();
            }
            MessageBox.Show("Done!");
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //合并某个工作空间下所有N开头的polygon Featureclass
            ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            gp.SetEnvironmentValue("workspace", @"E:\数据\temp");
            IGpEnumList featureClasses = gp.ListFeatureClasses("N*", "polygon", "");
            String featureClass = featureClasses.Next();
            String polygonsToUnion = "";

            while (featureClass != "")
            {
                Console.WriteLine(featureClass.ToString());
                polygonsToUnion += featureClass;
                featureClass = featureClasses.Next();
                if (featureClasses != null)
                {
                    polygonsToUnion += ";";
                }
            }
            Union union = new Union(polygonsToUnion, @"E:\数据\temp" + "\\" + "BIGUnioned.shp");
            gp.Execute(union, null);
            MessageBox.Show("Done!");

        }

        private void button6_Click(object sender, EventArgs e)
        {
            //调用IRasterGeometryProc,resample raster
            IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactory();
            IWorkspace workspace;
            workspace = workspaceFactory.OpenFromFile(@"E:\数据\GTDSSJ", 0); //inPath栅格数据存储路径

            IRasterWorkspace rastWork = (IRasterWorkspace)workspace;
            IRasterDataset rastDataset;
            rastDataset = rastWork.OpenRasterDataset("12.img") as IRasterDataset;//inName栅格文件名

            IRaster raster = rastDataset.CreateDefaultRaster();

            IRasterGeometryProc rastGeoProc = new RasterGeometryProcClass();
            rastGeoProc.Resample(rstResamplingTypes.RSP_NearestNeighbor,10.0, raster);
          
            ISaveAs2 saveAs = (ISaveAs2)raster;
            //saveAs.SaveAs("newnewnew.jpg", workspace, "JPG");
            //第三个参数有严格的格式要求 "IMAGINE Image" "TIFF" "HDF4" 具体见帮助
            saveAs.SaveAs("NewResampled3.img", workspace, "IMAGINE Image");

            //IRasterStorageDef rastStorageDef = new RasterStorageDefClass();
            //rastStorageDef.CompressionType = esriRasterCompressionType.esriRasterCompressionLZ77;
            //rastStorageDef.CompressionQuality = 1;
            //IRasterDataset newRastDataSet = null;
            //newRastDataSet=saveAs.SaveAsRasterDataset("GenNew22.img", workspace, "IMAGE", rastStorageDef);

            MessageBox.Show("Done!");

 


        }

        private void button7_Click(object sender, EventArgs e)
        {
            //构造Geoprocessor
            ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();
            //设置参数
            ESRI.ArcGIS.SpatialAnalystTools.ExtractByMask mask = new ExtractByMask();
            mask.in_raster = @"E:\数据\A2000049.h26v04.005.img";
            mask.in_mask_data = @"E:\数据\hebei";
            mask.out_raster = @"E:\数据\A2000049.h26v04.005_Marked";
            RunTool(gp, mask, null);

            //ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect();
            //intersect.in_features = @"E:\数据\temp\New_Shapefile.shp;E:\数据\temp\New_Shapefile_Intersect.shp";
            //intersect.out_feature_class = @"E:\数据\temp\intersectOne.shp";
            //intersect.join_attributes = "ONLY_FID";
            //执行Intersect工具
            //RunTool(gp, intersect, null);

            MessageBox.Show("Done!");
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

  }

}

 

 

Board logo

标题: [已解决] 影像数据的裁切和保存(源代码) [打印本页]


作者: lsbocai    时间: 2008-5-28 11:11     标题: 影像数据的裁切和保存(源代码)

因为问题已经解决,现将代码整理给大家。

影像数据的裁切我是参考的scrsgjh的帖子(vb的代码),原帖地址http://bbs.esrichina-bj.cn/ESRI/viewthread.php?
tid=4152&highlight=%B6%E0%B1%DF%D0%CE%2Bscrsgjh

//影像裁切
IGeometry clipGeo = axMapControl1.TrackPolygon();  //
ILayer layer = axMapControl1.get_Layer(i);   //要裁切的影像图层
IRasterLayer pRasterLayer = layer as IRasterLayer;
IRaster pRaster = pRasterLayer.Raster;
IRasterProps pProps = pRaster as IRasterProps;
object cellSizeProvider = pProps.MeanCellSize().X;
IGeoDataset pInputDataset = pRaster as IGeoDataset;
IExtractionOp pExtractionOp = new RasterExtractionOpClass();
IRasterAnalysisEnvironment pRasterAnaEnvir = pExtractionOp as IRasterAnalysisEnvironment;
pRasterAnaEnvir.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSizeProvider);
object extentProvider = clipGeo.Envelope;
object snapRasterData = Type.Missing;
pRasterAnaEnvir.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref extentProvider, ref snapRasterData);
IGeoDataset pOutputDataset = pExtractionOp.Polygon(pInputDataset, clipGeo as IPolygon, true);
IRaster clipRaster;  //裁切后得到的IRaster
if (pOutputDataset is IRasterLayer)
{
    IRasterLayer rasterLayer = pOutputDataset as IRasterLayer;
    clipRaster = rasterLayer.Raster;
}
else if (pOutputDataset is IRasterDataset)
{
    IRasterDataset rasterDataset = pOutputDataset as IRasterDataset;
    clipRaster = rasterDataset.CreateDefaultRaster();
}
else if (pOutputDataset is IRaster)
{
    clipRaster = pOutputDataset as IRaster;
}
else
{
    return;
}

//保存裁切后得到的clipRaster

//如果直接保存为img影像文件
IWorkspaceFactory pWKSF = new RasterWorkspaceFactoryClass();
IWorkspace pWorkspace = pWKSF.OpenFromFile(@"C:\temp", 0);
ISaveAs pSaveAs = clipRaster as ISaveAs;
pSaveAs.SaveAs("test.img", pWorkspace, "IMAGINE Image");

//如果保存在mdb中
IRasterStorageDef pRasterStorageDef = new RasterStorageDefClass();
pRasterStorageDef.CompressionType = esriRasterCompressionType.esriRasterCompressionJPEG2000;
pRasterStorageDef.CompressionQuality = 50;
pRasterStorageDef.TileHeight = 128;
pRasterStorageDef.TileWidth = 128;
IWorkspaceFactory pWKSF = new AccessWorkspaceFactoryClass();
IWorkspace pWorkspace = pWKSF.OpenFromFile(@"C:\temp\test.mdb", 0);
ISaveAs2 pSaveAs = clipRaster as ISaveAs2;
pSaveAs.SaveAsRasterDataset("test", pWorkspace, "gdb", pRasterStorageDef);

//也可以使用IRasterWorkspaceEx的SaveAsRasterDataset方法保存到mdb中
IWorkspaceFactory pWKSF = new AccessWorkspaceFactoryClass();
IWorkspace pWorkspace = pWKSF.OpenFromFile(@"C:\temp\test.mdb", 0);
IRasterWorkspaceEx pRasterWKS = pWorkspace as IRasterWorkspaceEx;
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 = axMapControl1.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 = axMapControl1.SpatialReference;
IRasterDataset pRasterDataset = pRasterWKS.SaveAsRasterDataset("test", clipRaster, pRasterStorageDef, "", pRasterDef,
pGeoDef);
//其实参数可以不用设置,直接:
IRasterDataset pRasterDataset = pRasterWKS.SaveAsRasterDataset("test", clipRaster, null, "", null, null);

[ 本帖最后由 lsbocai 于 2008-5-29 17:44 编辑 ]


作者: gaojuncq123    时间: 2008-5-28 11:32

ISaveAs接口。。。。


作者: lsbocai    时间: 2008-5-28 14:53     标题: 回复 2# 的帖子

试了ISaveAs,不行啊


作者: xiaof22    时间: 2008-5-28 16:54

IRasterWorkspaceEx接口提供以下方法:
CreateRasterCatalog:Creates a new raster catalog.
CreateRasterDataset :Creates a new raster dataset.
DeleteRasterCatalog :Deletes a raster catalog.
DeleteRasterDataset :Deletes a raster dataset.
OpenRasterCatalog :Opens an existing raster catalog.
OpenRasterDataset :Opens an existing raster dataset.
RegisterAsRasterCatalog: Registers as a RasterCatalog.
RegisterAsRasterDataset :Registers as a RasterDataset.
SaveAsRasterDataset :Creates a new raster dataset from another seed Raster.**
其中:
Public Function SaveAsRasterDataset ( _
    ByVal Name As String, _
    ByVal Raster As IRaster, _
    ByVal StorageDef As IRasterStorageDef, _
    ByVal ConfigKeyword As String, _
    ByVal RasterDef As IRasterDef, _
    ByVal GeometryDef As IGeometryDef _
) As IRasterDataset
应该可以
还有,非常感谢你帮我解决了licence的问题!

[ 本帖最后由 xiaof22 于 2008-5-28 16:58 编辑 ]


作者: lsbocai    时间: 2008-5-28 17:17

谢谢2位的指点。
我在帮助中看了saveas raster data的例子,但是按照例子代码所写,总是没有成功,我再琢磨琢磨。


作者: lsbocai    时间: 2008-5-28 17:31     标题: 回复 4# 的帖子

再问下xiaof22 ,
我使用SaveAsRasterDataset方法,提示错误“Failed to open raster dataset”,
使用CeateRasterDataset方法倒是可以创建一个空层,IRaster肯定是得到了的,可以在MapControl中显示出来

[ 本帖最后由 lsbocai 于 2008-5-29 10:22 编辑 ]


作者: xiaof22    时间: 2008-5-29 13:21

你能把你如何取得IRasterDataset对象的代码贴上来吗,我要根据代码看看问题出在什么地方。


作者: lsbocai    时间: 2008-5-29 14:30

IGeometry clipGeo = axMapControl1.TrackPolygon();  //
                      ILayer layer = axMapControl1.get_Layer(i);   //要裁切的影像图层

                       IRasterLayer pRasterLayer = layer as IRasterLayer;
                       IRaster pRaster = pRasterLayer.Raster;
                       IRasterProps pProps = pRaster as IRasterProps;
                       object cellSizeProvider = pProps.MeanCellSize().X;
                       IGeoDataset pInputDataset = pRaster as IGeoDataset;
                       IExtractionOp pExtractionOp = new RasterExtractionOpClass();
                       IRasterAnalysisEnvironment pRasterAnaEnvir = pExtractionOp as IRasterAnalysisEnvironment;
                       pRasterAnaEnvir.SetCellSize(esriRasterEnvSettingEnum.esriRasterEnvValue, ref cellSizeProvider);
                      object extentProvider = clipGeo.Envelope;
                      object snapRasterData = Type.Missing;
                       pRasterAnaEnvir.SetExtent(esriRasterEnvSettingEnum.esriRasterEnvValue, ref extentProvider, ref snapRasterData);
                       IGeoDataset pOutputDataset = pExtractionOp.Polygon(pInputDataset, clipGeo as IPolygon, true);
                        IRaster clipRaster;  //裁切后得到的IRaster
                       if (pOutputDataset is IRasterLayer)
                        {
                            IRasterLayer rasterLayer = pOutputDataset as IRasterLayer;
                            clipRaster = rasterLayer.Raster;
                        }
                        else if (pOutputDataset is IRasterDataset)
                        {
                            IRasterDataset rasterDataset = pOutputDataset as IRasterDataset;
                            clipRaster = rasterDataset.CreateDefaultRaster();
                        }
                        else if (pOutputDataset is IRaster)
                        {
                            clipRaster = pOutputDataset as IRaster;
                        }
                        else
                        {
                            return;
                        }
                    
//pWs是先前创建mdb是已有的IWorkspace
                        IRasterWorkspaceEx pRasterWKS = pWS as IRasterWorkspaceEx;
                        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 = axMapControl1.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 = axMapControl1.SpatialReference;

//使用CreateRasterDataset创建一个新层可以
                        IRasterDataset pRasterDataset1 = pRasterWKS.CreateRasterDataset("test1", 3, rstPixelType.PT_UCHAR, pRasterStorageDef, "", pRasterDef, pGeoDef);

//使用SaveAsRasterDataset保存已有的IRaster出现异常“Failed to open raster dataset”
                        IRasterDataset pRasterDataset2 = pRasterWKS.SaveAsRasterDataset("test2", pRaster, pRasterStorageDef, "", pRasterDef, pGeoDef);

xiaof22,你帮我看看


作者: lsbocai    时间: 2008-5-29 14:54

其实我觉得用ISaveAs接口也可以,但是:
(1)如果直接存为img文件
IWorkspaceFactory pWKSF = new RasterWorkspaceFactoryClass();
IWorkspace pWorkspace = pWKSF.OpenFromFile(@"C:\temp", 0);

ISaveAs pSaveAs = pRaster as ISaveAs;
pSaveAs.SaveAs("test.img", pWorkspace, "IMAGINE Image");
//异常:"对 COM 组件的调用返回了错误 HRESULT E_FAIL。"

(2)如果存到mdb中
IRasterStorageDef pRasterStorageDef = new RasterStorageDefClass();
pRasterStorageDef.CompressionType = esriRasterCompressionType.esriRasterCompressionJPEG2000;
pRasterStorageDef.CompressionQuality = 50;
pRasterStorageDef.TileHeight = 128;
pRasterStorageDef.TileWidth = 128;

IWorkspaceFactory pWKSF = new AccessWorkspaceFactoryClass();
IWorkspace pWorkspace = pWKSF.OpenFromFile(sLocalDb, 0);  //sLocalDb为mdb路径
ISaveAs2 pSaveAs = pRaster as ISaveAs2;
pSaveAs.SaveAsRasterDataset("test2", pWorkspace, "gdb", pRasterStorageDef);
//异常:"Failed to open raster dataset"

(3)如果存文件数据库gbb,呈高CPU运行死机状态

请大家帮我参详参详,谢谢。

[ 本帖最后由 lsbocai 于 2008-5-29 14:55 编辑 ]


作者: xiaof22    时间: 2008-5-29 14:59

IRasterDataset pRasterDataset2 = pRasterWKS.SaveAsRasterDataset("test2", pRaster, pRasterStorageDef, "", pRasterDef, pGeoDef);
你的test2貌似没有创建吧,你把它换成test1看看


作者: lsbocai    时间: 2008-5-29 15:12

如果用test1,会出异常“表test1已存在”。


作者: xiaof22    时间: 2008-5-29 15:50

我糊涂了,不对不对,和那没关系
你的代码没有问题,我在我电脑上运行了
你可以创建rasterdataset是吗?


作者: lsbocai    时间: 2008-5-29 15:52

是啊,我创建一个新的rasterdataset层没有问题


作者: xiaof22    时间: 2008-5-29 16:00     标题: 回复 9# 的帖子

第一个//异常:"对 COM 组件的调用返回了错误 HRESULT E_FAIL。"可能是文件已经存在了,我遇到过,把先前建的文件删掉就好了,不知道你的是不是这原因

对于第二个
这是我写的一个创建raster的例子,其中用到了SaveAsRasterDataset,工作的很好。你能建证明mdb建立的没问题,为什么会:"Failed to open raster dataset"我还真弄不明白

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        '打开工作空间
        Dim ws As IRasterWorkspace2
        Dim workspaceFact As IWorkspaceFactory
        workspaceFact = New RasterWorkspaceFactory
        ws = workspaceFact.OpenFromFile("c:/test", 0)

        '1.Define the spatial reference of the raster dataset.
        Dim sr As ISpatialReference
        sr = New UnknownCoordinateSystem

        '2.Define the origin for the raster dataset, which is the lower left corner of the raster.
        Dim origin As IPoint
        origin = New Point
        origin.PutCoords(15.0, 15.0)

        '3.Define the dimension of the raster dataset.
        Dim width As Integer 'the width of the raster dataset
        Dim height As Integer 'the height of the raster dataset
        Dim xCell As Double 'the cell size in x direction
        Dim yCell As Double 'the cell size in y direction
        Dim NumBand As Integer 'number of bands the raster dataset contains
        width = 100
        height = 100
        xCell = 30
        yCell = 30
        NumBand = 1

        '.Create a raster dataset in grid format.
        Dim rasterDS As IRasterDataset
        rasterDS = ws.CreateRasterDataset("sss", "GRID", origin, width, height, xCell, yCell, NumBand, rstPixelType.PT_UCHAR, sr, True)

        'the following code will add a raster data to the dataset created just now
        'Get the raster band.
        Dim bands As IRasterBandCollection
        Dim band As IRasterBand
        Dim rasterProps As IRasterProps
        bands = rasterDS
        band = bands.Item(0)
        rasterProps = band

        'Set NoData if necessary. For a multiband image, NoData value needs to be set for each band.
        rasterProps.NoDataValue = 255

        'Create a raster from the dataset.
        Dim raster As IRaster
        raster = rasterDS.CreateDefaultRaster

        'Create a pixel block.
        Dim pixelBlock As IPixelBlock3
        Dim blockSize As IPnt
        blockSize = New Pnt
        blockSize.SetCoords(width, height)
        pixelBlock = raster.CreatePixelBlock(blockSize)

        'Populate some pixel values to the pixel block.
        Dim pixels As System.Array
        Dim i, j As Integer
        pixels = CType(pixelBlock.PixelData(0), System.Array)
        For i = 0 To width - 1
            For j = 0 To height - 1
                If i = j Then
                    pixels.SetValue(Convert.ToByte(255), i, j)
                Else
                    pixels.SetValue(Convert.ToByte((i * j) / 255), i, j)
                End If
            Next j
        Next i
        pixelBlock.PixelData(0) = CType(pixels, System.Array)

        'Define the location that the upper left corner of the pixel block is to write.
        Dim upperLeft As IPnt
        upperLeft = New Pnt
        upperLeft.SetCoords(0, 0)

        'Write the pixel block.
        Dim rasterEdit As IRasterEdit
        rasterEdit = raster
        rasterEdit.Write(upperLeft, pixelBlock)

        '以下是将创建的iRaster保存为名为"b"的IRasterdataset,保存路径为c:/workspace/GeoDB.mdb
        Dim pAccessWorkspaceFactory As IWorkspaceFactory
        pAccessWorkspaceFactory = New AccessWorkspaceFactory

        Dim pWorkspace As IWorkspace
        pWorkspace = pAccessWorkspaceFactory.OpenFromFile("c:/workspace/GeoDB.mdb", 0)
        Dim wsx As IRasterWorkspaceEx
        wsx = pWorkspace

        Dim rec As IRasterDataset
        rec = wsx.SaveAsRasterDataset("b", raster, Nothing, "", Nothing, Nothing)

        '在mapcontrol中打开raster:
        Dim pRastLyr As IRasterLayer
        pRastLyr = New RasterLayer
        pRastLyr.CreateFromDataset(rec)
        AxMapControl1.AddLayer(pRastLyr)
        AxMapControl1.Refresh()


作者: lsbocai    时间: 2008-5-29 16:52

换了影像数据试了下,发现我所试验过的保存方法都是可以的。
开始我用的是一个46G的img影像,裁切一小块出来,怎么保存都不行。
然后换了比较小的数据试,各种保存方法都可以,但是裁切无效,保存的都是原数据,而不是裁切出来的小块。

无语了。


作者: xiaof22    时间: 2008-5-29 16:57     标题: 回复 15# 的帖子

你保存的是pRaster还是clipRaster


作者: lsbocai    时间: 2008-5-29 17:08

我错了,居然犯了这样的低级错误,
最近地震晃得头太晕了

[ 本帖最后由 lsbocai 于 2008-5-29 17:12 编辑 ]


作者: yangpingding    时间: 2008-5-29 18:43

好东西收藏了


作者: lll2007    时间: 2008-5-29 21:55

学习中...........


作者: Chilli_mm    时间: 2008-6-4 04:03

顶一下!!好东西


作者: lijian5277    时间: 2008-6-6 11:43     标题: ....................

好东西...............................


作者: hljzh_2008    时间: 2008-6-6 13:32     标题:

顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶

[ 本帖最后由 hljzh_2008 于 2008-6-6 13:33 编辑 ]


作者: knife114    时间: 2008-9-6 16:54

好东西,谢谢


作者: ilylm    时间: 2008-9-6 20:51

先收藏一下,为以后做准备,谢谢了!


作者: fanggis    时间: 2009-3-28 20:45

ding!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1


作者: willway    时间: 2009-6-27 14:36

好东西 参考下


作者: evergreenxq    时间: 2009-8-26 16:01

ding yi 个 谢谢


作者: superzjd    时间: 2009-8-26 16:17

很好,有参考价值呀!




欢迎光临 ESRI中国社区 (http://bbs.esrichina-bj.cn/ESRI/) Powered by Discuz! 7.0.0

posted on 2010-03-13 21:14  GIS的学习  阅读(2452)  评论(0编辑  收藏  举报