我只需要在DotSpatial中没有完全包含的相交功能。如果我使用feature.Intersects(),它会给我相交和包含的特性,而当我使用feature.Contains()时,它只给我包含的特性。
我已经像这样手动完成了。
feature1.Intersects(feature2) && !feature1.Contains(feature2)DotSpatial有什么方法可以直接做到这一点吗?
发布于 2015-04-23 07:34:57
因此,为了在不执行交集和“不包含”测试的情况下执行此操作,您可以使用Touches。在入门指南中,你可以在这里找到:Getting Started Guide Touches应该有你想要的定义。请注意,在底部的示例中,即使考虑了所有县,Placer县本身也不会出现在结果集中,但它周围的每个县都会出现。

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

https://stackoverflow.com/questions/28803505
复制相似问题