专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > CGI

arcgis engine C#中在map上绘制矩形并裁切

发布时间:2010-05-20 14:01:29 文章来源:www.iduyao.cn 采编人员:星星草
arcgis engine C#中在地图上绘制矩形并裁切
绘制矩形需要用到橡皮条工具 RubberBand

            ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

            // Constant.
            screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)
              ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit cast.
            ESRI.ArcGIS.Display.IRgbColor rgbColor = new
              ESRI.ArcGIS.Display.RgbColorClass();
            rgbColor.Red = 255;

            ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit cast.
            ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new
              ESRI.ArcGIS.Display.SimpleFillSymbolClass();
            simpleFillSymbol.Color = color;

            ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as
              ESRI.ArcGIS.Display.ISymbol; // Dynamic cast.
            ESRI.ArcGIS.Display.IRubberBand rubberBand = new
              ESRI.ArcGIS.Display.RubberEnvelopeClass();
            ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay,
              symbol);
            screenDisplay.SetSymbol(symbol);
            screenDisplay.DrawRectangle(geometry as ESRI.ArcGIS.Geometry.IEnvelope);
            // Dynamic cast.
            screenDisplay.FinishDrawing();


裁切代码如下,其中envelope是RubberBand工具产生的IGeometry

            String tempDirName = @"E:tmptttbar";
            String tempFileName = Guid.NewGuid().ToString() + ".tif";
            String tempFullName = tempDirName + @"" + tempFileName;
            ILayer pLayer = axMapControl1.get_Layer(0);
            IRasterLayer rasterLayer = (IRasterLayer)pLayer;

            IRaster pRaster = rasterLayer.Raster;

            //Initialize the Clip tool class.
            Clip clip = new Clip();
            //Set the parameters.
            clip.in_raster = pRaster;
            clip.out_raster = tempFullName;

            //The clipping envelope.
            //Comment this line out if clipping with a given dataset.
            clip.rectangle = String.Format("{0} {1} {2} {3}", envelope.XMin, envelope.YMin, envelope.XMax, envelope.YMax);

            //Initialize the geoprocessor and execute the Clip tool.
            Geoprocessor geoprocessor = new Geoprocessor();
            object outRaster = geoprocessor.Execute(clip, null);


一开始尝试使用RasterLayerExport导出特定区域的栅格,结果发现原来float型的值成了int
api上信誓旦旦说
引用
The RasterLayer property is used to set the input RasterLayer to the RasterLayerExport object; this is a required property. Normally, a raster layer is associated with a raster renderer by default. You can change the raster renderer to what you need. If you don't want to use the raster renderer to filter the pixel values during the export, remove the raster renderer from the raster layer before passing it to the RasterLayerExport object


呵呵,怎么remove the raster renderer啊,也不说清楚...差评
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: