• ArcGISEngine实现图层输出kml


    来自:http://www.gisall.com/html/72/124272-6796.html

    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);

  • 相关阅读:
    Dreamweaver CS4无法启动:xml parsing fatal error..Designer.xml错误解决方法
    strcpy() strcat() strcmp() gets() puts()
    使用友元,编译出错fatal error C1001: INTERNAL COMPILER ERROR (compiler file 'msc1.cpp', line 1786) 的解决
    HashMap按key排序
    转Oracle数据类型及存储方式【E】
    JAVA_java.util.Date与java.sql.Date相互转换
    Oracle_复制表跟往表插数据
    java_Struts学习例子
    ORA01033: ORACLE initialization or shutdown in progressORACLE
    dorado勾选修改的时候总是选择第一条记录解决办法.
  • 原文地址:https://www.cnblogs.com/gisoracle/p/2570554.html
Copyright © 2020-2023  润新知