所以为了做到这一点而不必执行相交和“不包含”测试,您可以使用触摸。从您可以在这里找到的入门指南:Getting Started Guide触摸应该有你想要的定义。在底部的例子中注意到,尽管考虑了所有的县,普莱塞县本身并没有出现在结果集中,但是它周围的每个县都有。
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);
}
来源
2015-04-22 23:34:57
Ted