C#之ArcGIS二次开发

C#之ArcGIS二次开发根据图层名称获取图层publicIFeatureLayergetLayer(AxMapControlaxMapControl,stringlayerName){if(axMapControl.LayerCount>0){for(inti=0;i

大家好,又见面了,我是你们的朋友全栈君。

根据图层名称获取图层

public IFeatureLayer getLayer(AxMapControl axMapControl, string layerName)
{
    if (axMapControl.LayerCount > 0)
    {
        for (int i = 0; i < axMapControl.LayerCount; i++)
        {
            ILayer pLayer = axMapControl.get_Layer(i);
            if (pLayer.Name == layerName)
                return pLayer as FeatureLayer;
        }
    }
    return null;
}

按条件查询图层要素,并闪烁

public void searchFeatures(AxMapControl mapControl,string sqlfilter,IFeatureLayer pFeatureLayer)
{
    IFeatureLayer pFeatLyr = pFeatureLayer;
    IQueryFilter pFilter = new QueryFilterClass();
    pFilter.WhereClause = sqlfilter;
    IFeatureCursor pFeatCursor = pFeatLyr.Search(pFilter,true);
    IFeature pFeat = pFeatCursor.NextFeature();
    while (pFeat != null)
    {
        if (pFeat != null)
        {
            ISimpleFillSymbol pFillsyl = new SimpleFillSymbolClass();
            RgbColor pRgbColor=new RgbColor();
            pRgbColor.Red=255;
            pRgbColor.Green=0;
            pRgbColor.Blue=0;
            pFillsyl.Color = pRgbColor;
            object oFillsyl = pFillsyl;
            IPolygon pPolygon = pFeat.Shape as IPolygon;
            mapControl.FlashShape(pPolygon, 15, 20, pFillsyl);
            mapControl.DrawShape(pPolygon, ref oFillsyl);
        }
        pFeat = pFeatCursor.NextFeature();
    }
}

sqlfilter为查询条件,如查询layer图层中,属性字段ID<10的要素:searchFeatures(axMapControl1, “ID < 10”, layer);

建立缓冲区,并添加到图层

public void SetBuffer(AxMapControl m_map, string LayerName, double bufferDistance,string OutputPath)
{
    try
    {
        IFeatureLayer layer = getLayer(m_map,LayerName);
        if (layer == null)
        {
            LogHelper.Debug("图层不存在");  #这里是自己写的日志记录方法
            return;
        }
        Geoprocessor gp = new Geoprocessor();
        gp.OverwriteOutput = true;
     
        ESRI.ArcGIS.AnalysisTools.Buffer buffer = new ESRI.ArcGIS.AnalysisTools.Buffer(layer, OutputPath, bufferDistance.ToString() + " Meters");
        IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(buffer, null);
        if (results.Status != esriJobStatus.esriJobSucceeded)
        {
            LogHelper.Debug("为图层" + layer.Name + "建立缓冲区失败\r\n");
        }

        int k = OutputPath.LastIndexOf('\\');
        string pOutFeatclsName = OutputPath.Substring((k + 1)).Trim();
        string strFolder = OutputPath.Substring(0, k);
        m_map.AddShapeFile(strFolder, pOutFeatclsName);   #添加到图层
    }
    catch (Exception ex)
    {
        LogHelper.Error(ex.Message);
    }
}


版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/148699.html原文链接:https://javaforall.net

(0)
上一篇 2022年6月26日 下午11:36
下一篇 2022年6月26日 下午11:36


相关推荐

  • Windows10 系统下cuda安装教程,小白教程 !很详细!!「建议收藏」

    Windows10 系统下cuda安装教程,小白教程 !很详细!!「建议收藏」Windows10系统下cuda安装教程1.查看适合自己电脑的cuda版本1.点击Windows+R输入nvidia-smi看一下自己电脑支持的conda版本是:根据下图白框标出的地方可以看出我的conda版本是10.02.下载cuda地址:https://developer.nvidia.com/zh-cn/cuda-toolkit下载好了以后,根据下列图示依次进行安装2.1点击下载好的文件。2.2点击运行2.3选择文件存储位置,然后点击ok2.4等待安装完成

    2022年5月29日
    93
  • hadoop常用命令汇总[通俗易懂]

    hadoop常用命令汇总[通俗易懂]1、查看目录下的文件列表:hadoop fs –ls [文件目录]hadoop fs -ls -h /lance 2、将本机文件夹存储至hadoop上:hadoop fs –put [本机目录] [hadoop目录] hadoop fs -put lance / 3、在hadoop指定目录内创建新目录:hadoop fs –mkdir [目录] hadoop fs -mkdir /lance4、在…

    2022年6月24日
    32
  • PhotoShop算法实现进阶-浮雕滤镜-灰度浮雕(三十一)

    PhotoShop算法实现进阶-浮雕滤镜-灰度浮雕(三十一)PhotoShop算法实现进阶-浮雕滤镜-灰度浮雕(三十一)kezunhai@gmail.comhttp://blog.csdn.net/kezunhai    浮雕效果可谓花样百出,但他们主要是基于图像相邻像素的差值来实现的。对于大多数图像而

    2022年6月20日
    35
  • 什么是泛型

    什么是泛型//泛型:就是一种不确定的数据类型。//比如:ArrayList&lt;E&gt;E就是泛型。这种不确定的数据类型需要在使用这个类的时候才能够确定出来。//泛型可以省略,如果省略,默认泛型是Object类型。//泛型的好处://1.省略了强转的代码。//2.可以把运行时的问题提前到编译时期。publicclassDemo01Generic{…

    2022年6月29日
    32
  • 保姆级的Seedance 2.0实操教程

    保姆级的Seedance 2.0实操教程

    2026年3月13日
    2
  • win10 禁止自动更新(修改注册表)

    win10 禁止自动更新(修改注册表)参考:https://blog.csdn.net/qq_40833810/article/details/89045074?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task第一步:按win+R,输入regedit,回车打开注册表编辑器,…

    2022年5月5日
    124

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号