ThinkGeo.com    |     Documentation    |     Premium Support

How to find intersection

Hi,


I want to find all the intersections of a polygon and a road layer. How can i?


Thx.


Li


 



Hi Senlin,


Thanks for your post!
 
If you have a polygon and a road layer, you can find the intersecting features from the road layer like this:

 

roadLayer.Open();
Collection<Feature> intersectingFeatures = roadLayer.QueryTools.GetFeaturesIntersecting(polygon, ReturningColumnsType.NoColumns);
roadLayer.Close();


Any more questions please let me know.
 
Thanks,
 
sun

sun,


Thank u very much.



Sun, 

I tried your method, and I got the road features which are intersecting with the polyline(Sorry, not polygon). But what I want is the intersection points of road layer and polyline layer, that means the points exactly on both road layer and polyline. 



Could you help me? 



Senlin



Senlin


I think you can use this block of code to implement your requirement:
 


roadLayer.Open();
Collection<Feature> intersectingFeatures = roadLayer.QueryTools.GetFeaturesIntersecting(targetMultiLineShape, ReturningColumnsType.NoColumns);
roadLayer.Close();

MultipointShape resultPoints = new MultipointShape();
foreach (Feature feature in intersectingFeatures)
{
   MultipointShape resultPointsForOneFeature = targetMultiLineShape.GetCrossing(feature.GetShape());
   foreach (PointShape point in resultPointsForOneFeature.Points)
   {
       resultPoints.Points.Add(point);
   }
}


 
The intersecting points will be contains in the resultPoints.
 
Any more questions please let me know.
 
Thanks,
 
sun

Hi sun, 
 It works. 
 Thank you! 
  
 Senlin

You are welcome, Senlin,


Any more questions please let me know.
 
Thanks,
 
Sun