博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ArcGISEngine实现图层输出kml
阅读量:4885 次
发布时间:2019-06-11

本文共 2255 字,大约阅读时间需要 7 分钟。

转自:

ArcGIS的转换工具(ConversionTools)提供了将图层输出到kml的接口LayerToKML,

这个方法被封装在ESRI.ArcGIS.ConversionTools中

    LayerToKML接口的输入参数layer接收两种类型的参数:本地磁盘的图层文件(*.lyr)、内存中的图层。

n  将本地磁盘图层文件(*.lyr)输出kml

// LayerToKML接口输出kml

Geoprocessor pGeoProcessor = new Geoprocessor();

   ESRI.ArcGIS.ConversionTools.LayerToKML pLayerToKML = new ESRI.ArcGIS.ConversionTools.LayerToKML();

   pLayerToKML.layer = @"D:\slayer.lyr";

   pLayerToKML.out_kmz_file = "C:\\pkm.kmz";

   pLayerToKML.layer_output_scale = 10000.0;

   pGeoProcessor.OverwriteOutput = true;

   IGeoProcessorResult resultGeo =

           (IGeoProcessorResult)pGeoProcessor.Execute(pLayerToKML, null);

   if (resultGeo.Status == esriJobStatus.esriJobSucceeded)

                    MessageBox.Show("执行成功!", "输出KML", MessageBoxButtons.OK, MessageBoxIcon.Information);

   else

                    MessageBox.Show("执行Error!", "输出KML", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

n  将图层选择集输出kml

IFeatureLayer pFeatureLayer = axMapControl1.get_Layer(0) as IFeatureLayer;

//设置空间查询范围条件

ISpatialFilter pQueryFilter = new SpatialFilterClass();

pQueryFilter.Geometry = pPoly;

pQueryFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

//生成图层在此范围内的选择

IFeatureSelection pFeatureSele = pFeatureLayer as IFeatureSelection;

pFeatureSele.SelectFeatures(pQueryFilter, esriSelectionResultEnum.esriSelectionResultNew, false);

//IFeatureLayerDefinition接口 在当前将图层选择集 基础上创建新的图层

IFeatureLayerDefinition2 pFLayerDef = pFeatureLayer as IFeatureLayerDefinition2;

IFeatureLayer pNewLyr = pFLayerDef.CreateSelectionLayer("uuu", true, null, null);

// LayerToKML接口输出kml

ESRI.ArcGIS.Geoprocessor.Geoprocessor pGeoProcessor = new ESRI.ArcGIS.Geoprocessor.Geoprocessor();

     ESRI.ArcGIS.ConversionTools.LayerToKML pLayerToKML = new ESRI.ArcGIS.ConversionTools.LayerToKML();

     pLayerToKML.layer = pNewLyr;

     pLayerToKML.out_kmz_file ="C:\\NewKML.kmz" ;

     pLayerToKML.layer_output_scale = 10000.0;

     pGeoProcessor.OverwriteOutput = true;

     IGeoProcessorResult resultGeo =

                    (IGeoProcessorResult)pGeoProcessor.Execute(pLayerToKML, null);

     if (resultGeo.Status == esriJobStatus.esriJobSucceeded)

                    MessageBox.Show("执行成功!", "输出KML", MessageBoxButtons.OK, MessageBoxIcon.Information);

     else

                    MessageBox.Show("执行Error!", "输出KML", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

转载于:https://www.cnblogs.com/LCGIS/archive/2013/05/30/3107375.html

你可能感兴趣的文章
8-1-组队赛
查看>>
codility: CountTriangles
查看>>
赛斯说
查看>>
python 中的pipe
查看>>
(SQL Analyzer services)定义链接维度
查看>>
squid
查看>>
系统开发管理、架构与设计步步谈随笔索引
查看>>
Java的时间空间复杂度详解
查看>>
有效防止SQL注入漏洞
查看>>
Linux chown命令
查看>>
十、I/O流——4-输入、输出流体系
查看>>
十二、网络编程——4-基于UDP协议的网络编程
查看>>
异常处理与调试6 - 零基础入门学习Delphi55(完)
查看>>
if语句三种形式
查看>>
正则表达式之字符串验证
查看>>
codeblocks如何支持_tmain?可移植代码的编码推荐
查看>>
省市联动 填坑
查看>>
canvas写的一个小时钟demo
查看>>
原来今天是冬至
查看>>
又混了一天班
查看>>