首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >与DotSpatial中的另一个要素相交但不包含要素

与DotSpatial中的另一个要素相交但不包含要素
EN

Stack Overflow用户
提问于 2015-03-02 13:56:47
回答 1查看 623关注 0票数 2

我只需要在DotSpatial中没有完全包含的相交功能。如果我使用feature.Intersects(),它会给我相交和包含的特性,而当我使用feature.Contains()时,它只给我包含的特性。

我已经像这样手动完成了。

代码语言:javascript
复制
feature1.Intersects(feature2) && !feature1.Contains(feature2)

DotSpatial有什么方法可以直接做到这一点吗?

EN

回答 1

Stack Overflow用户

发布于 2015-04-23 07:34:57

因此,为了在不执行交集和“不包含”测试的情况下执行此操作,您可以使用Touches。在入门指南中,你可以在这里找到:Getting Started Guide Touches应该有你想要的定义。请注意,在底部的示例中,即使考虑了所有县,Placer县本身也不会出现在结果集中,但它周围的每个县都会出现。

代码语言:javascript
复制
    IFeatureSet counties;
    IFeature placer;

    private void Form1_Load(object sender, EventArgs e)
    {
        // Open a FeatureSet from a shapefile containing Counties
        counties = Shapefile.Open("D:\\Data\\Counties\\CntyBnds_ESRI.shp");

        // Loop through the features to find the Feature with the Name equal to "Placer"
        foreach (IFeature f in counties.Features)
        {
            if (f.DataRow["NAME"].ToString() == "Placer")
            {
                placer = f;
                break;
            }
        }

        // Add the counties layer to the map to show all the counties
        this.map1.Layers.Add(counties);
    }

    private void button1_Click(object sender, EventArgs e)
    {

        FeatureSet result = new FeatureSet();

        // Cycle thorugh the shapes using the Touches operation
        foreach (IFeature county in counties.Features)
        {
            if (county.Touches(placer))
            {
                // Add only the features that touch to the result dataset.
                result.AddFeature(county);
            }
        }

        // Add the result to the map.
        this.map1.Layers.Add(result);
    }

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28803505

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档