Select to view content in your preferred language

IFeatureCursor.Search(spatialFilter,...) has too much tolerance

770
3
09-07-2011 06:49 AM
SebastianKrings
Frequent Contributor
Hi,

I have a couple of points and some line features. I know that every point lies exactly on one of the lines. For each point I now want to identify the underlying line.#
For this I use the Search Method of IFeatureCursor and a spatial Filter.

It works (not) fine.
Some often there are more than one "underlying" line found. But the lines never intersect or touch each other. So there seems to be some tolerance. I thought of the envelope but as I can see, the envelope is no area but a single point, isnt it?
[ATTACH]8801[/ATTACH]


Thanks for ideas and aswers!

Here the code:

IEnvelope envelope = point.Envelope;
                //envelope.Expand(1.1, 1.1, true);

                string shapeFieldName = contourClass.ShapeFieldName;

                // Create a new spatial filter and use the new envelope as the geometry    
                ISpatialFilter spatialFilter = new SpatialFilterClass();
                //spatialFilter.Geometry = envelope;
                spatialFilter.Geometry = point;
                spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;
                spatialFilter.set_OutputSpatialReference(shapeFieldName, point.SpatialReference);
                spatialFilter.GeometryField = shapeFieldName;

                // Do the search
                IFeatureCursor featureCursor = contourClass.Search(spatialFilter, false);
0 Kudos
3 Replies
DubravkoAntonic
Occasional Contributor
Your spatial relation is wrong.
Envelope of line is containing rectangle this is reason of returning a lot more features then you expected.
I sugest to use

esriSpatialRelEnum.esriSpatialRelIntersect - geometry intersection.
0 Kudos
AlexanderGray
Honored Contributor
Antonic is correct esriSpatialRelIntersect will return the right line.  However this seems like a very inefficient method.  If each point is on one and only one line, I would recommend a spatialjoin.  You only have to set it up once and then you can iterate through all the features and get the line objectID.
0 Kudos
SebastianKrings
Frequent Contributor
hi

thanks a lot, that mus be it

yes you're right ist very insufficient...

ich habe some lines and some points
every point lies on one line
but one line can have more points than only one or no point

this way is until now the only way which work at all...
with spaital join you mean something like this?:
http://forums.arcgis.com/threads/36765-JoinData-Can-t-create-output-feature-class.-the-workspaces-is....

sorry, but did not work
may you can help in the other topic

thanks!
0 Kudos