1

the problem is i have to display those points on arcmap that lies inside the envelope.I am explaining what i have done so far. I have one point feature class say featureclass ,open it and used one ARCGIS Snippet i.e. GetActiveviewFromArcmap() and constructed one envelope as-:

Iactiveview pactiveview=GetActiveviewFromArcmap(m_application);
Ienvelope penvelope=new EnvelopeClass();
penvelope=pactiveview.extent;
penvelope.QueryCoord(out minx, out miny,out maxX,out maxY);

Ispatialfilter sp=New IspatialfilterClass();
sp.geometry=penvelope;
sp.geometryfield=featureclass.shapefieldname;
sp.spatialrel=esrispatialrelenum.esrispatialrelIntersects;



Ifeaturecursor fc=featureclass.Search(sp,false);
Ifeature feature=featurecursor.nextfeature();

What i have to do is to display the output of this spatial query on arcmap.how i will retrieve the selectionset of spatialfilter query and how to diaplay it on arcmap.
1

Do you want these results in a new featureclass? If you do you will have to create one inside a workspace and then add your features to it in order to create a layer to add to the map.

Add features to a featureclass like this using the feature from your spatial query (sorry it's in vb.net):

feature = pFeatureClass.CreateFeature()
feature.Store()

Then create a featurelayer from your featureclass and add it to the map:

Dim pFeatureLayer as IFeatureLayer
pFeatureLayer.FeatureClass = pFeatureClass
pFeatureLayer.Name = "Results"
Dim pMap as IMap = pMxDoc.FocusMap
pMap.AddLayer(pFeatureLayer)

If you don't want the results in a new featureclass you can just create a selection which will show on the map (using featureclass.select instead of featureclass.search)

Dim pSelectionSet as ISelectionSet
pSelectionSet = pFeatureClass.select(<parameters here>)
' might need to refresh the screen so that the selection appears
pMxDoc.ActiveView.Refresh()

A third option is to create graphic objects from your features and add these to the map view, if that's what you're after.

  • Hey..thanx for reply I did this but selected result is not showing on map . Iselectionset sSet=featureclass.Select(sp,esriSelectionType.esriSelectionTypeIDSet,esriSelectionOption.esriSelectionOptionNormal,null) pActiveView.refresh(); This is a problem i have to display the result on arcmap. – cynthia Dec 18 '13 at 12:09
  • As far as third option is concerned i did that but in that case only one graphic object is displaying on map(point){from point feature class, i have taken lat(x),long(y) } although there are 19 objects that satisfying the result.I want that when i use my tool and click on it then all 19 point object display on map that satisfy the query. – cynthia Dec 18 '13 at 12:09
  • If only one graphic object is showing on the map then you're probably only adding one feature to it. Loop through each feature held by your search cursor and add each one. (use a 'while feature isnot nothing' loop and call nextfeature() each time). – pvdev Dec 18 '13 at 12:25
  • I used the code given below but on result its displaying only one graphicobject on arcmap.I am not understanding is there any problem of storing of point or whatelse.Please findout – cynthia Dec 19 '13 at 5:39
0
IgraphicContainer pgc;
Ielement pElement;
pElement=new MarkerElementClass();
Ipoint ppoint=new PointClass();

Ifeature feature=featurecursor.NextFeature();
while(feature!=null)
{double x=Convert.ToDouble(feature.get_value(featureclass.fields.findfield("LAT")));
 double y=Convert.ToDouble(feature.get_value(featureclass.fields.findfield("LON")));
 ppoint.PutCoord(x,y);
 pElement.Geometry=ppoint;
 ppoint.AddElement(pElement,0);
 pActiveview.Refresh();
featurecursor.NextFeature();}   
  • I used the above mentioned code but on result its displaying only one graphicobject on arcmap.I am not understanding is there any problem of storing of point or whatelse.Please findout.. – cynthia Dec 19 '13 at 5:00
  • Is there any problem with graphic container or retrieving of spatial query result.I believe i have used the right approach but not able to understand why m not getting the expected result?? – cynthia Dec 20 '13 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.