find features in all layers around a point feature

934
9
04-08-2014 12:53 AM
DavidXavier
New Contributor
Hi,
    How can I find features in all layers around a point feature.Currently i can able to identify single layer.

Suggestion appreciated.!!

Thank in advance
0 Kudos
9 Replies
NeilClemmons
Regular Contributor III
Call IMap.SelectByShape.  It will query all feature layers in the map using the geometry you give it.
0 Kudos
DavidXavier
New Contributor
Thanks for your Reply....

   I tired but it select only one feature. please send any sample code...
0 Kudos
NeilClemmons
Regular Contributor III
Have you read the documentation for the method?
0 Kudos
KevinYanuk
Occasional Contributor
Thanks for your Reply....

   I tired but it select only one feature. please send any sample code...



If I'm understanding you correctly, you could use a SpatialFilter with a search distance to get all intersecting features from that point, i.e.:


       public static List<IFeature> SelectByGeometry(this IFeature feature, IFeatureLayer fc, double searchDist) {
            IFeatureCursor curs = null;
            List<IFeature> features = new List<IFeature>();
            
            try {
                SpatialFilter sf = new SpatialFilterClass();
                sf.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

                ITopologicalOperator top = (ITopologicalOperator)feature.ShapeCopy;
                sf.Geometry = top.Buffer(Convert.ToDouble(searchDist));
                
                curs = fc.Search(sf, false);
                var boundFeat = curs.NextFeature();
                while (boundFeat != null)
                {
                    features.Add(boundFeat);
                    boundFeat = curs.NextFeature();
                }
                return features;
            }
            finally
            {
                if (curs != null) Marshal.ReleaseComObject(curs);
            }
        }

0 Kudos
DavidXavier
New Contributor
Thanks for your reply....

   Your searching Single feature layer.. I need to find intersecting features(all layers features) around a point feature.
0 Kudos
KevinYanuk
Occasional Contributor
Thanks for your reply....

   Your searching Single feature layer.. I need to find intersecting features(all layers features) around a point feature.



So use that method when iterating a list of IFeatureLayers from the map:

if you want to get the layers in a map:


List<IFeatureLayer> myLayers = new List<IFeatureLayer>();
var layerUID = new UID();
layerUID.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}";
var eLayer = _ArcMap.Document.FocusMap.get_Layers(layerUID, true);
var layer = eLayer.Next();
while (layer != null)
{
     var featureLayer = (IFeatureLayer)layer;
     myLayers.Add(featureLayer);
     layer = eLayer.Next();
}



then use the method I posted before on this list on your feature:


List<IFeature> intersectedFeatures = null;
foreach(var featureLayer in myList)
{
     intersectedFeatures.AddRange(myFeature.SelectByGeometry(featureLayer, 10)); // 10 is an arbitrary buffer size.. you would use whatever you want here
}

0 Kudos
DavidXavier
New Contributor
Thanks for your effect kyanuk1.
Ur searching layer level but its better feature level...
For example I am having 20 layers but point intersecting 2 or 3 layer ..so I need point intersecting objects
0 Kudos
KevinYanuk
Occasional Contributor
Thanks for your effect kyanuk1.
Ur searching layer level but its better feature level...
For example I am having 20 layers but point intersecting 2 or 3 layer ..so I need point intersecting objects


Not sure I understand... do you want to find all features intersecting an area (buffer) around a single point?  From specific layers?
0 Kudos
DavidXavier
New Contributor
yes kyanuk1. Need what are all the point layers available inside the buffer.


Thanks..
0 Kudos