[GIS] ArcObjects C#: select intersecting polylines

arcobjectscintersectionline

My questions seems trivial but it is a real blocker for me. So please help!!!

How can I, using ArcObjects with C#, select only those polylines in one layer that intersect with each other?

It sounds like a very straight forward task, but I can't find another way than using a feature cursor. Which would take ages and is not efficient from my point of view.

Many Thanks in advance!

Hubert

Best Answer

You can do this by using a topology. The workflow would depend on your data source and processing environment. One way to accomplish this:

  • Create a temporary file geodatabase workspace
  • Create a feature dataset inside this workspace
  • Import your feature class into the feature dataset
  • Create a topology based on the imported feature class and set the geometry rules (Esri Topology Rule Constants)
  • Validate the topology
  • Cast the ITopology to IErrorFeatureContainer and loop through the errors
  • The OID of each offending feature is stored in the error object, you can use the OID to select your features