More

Vb.net ArcObjects is there a function the same as “Select Features by Polygon” of ArcMap's tool

Vb.net ArcObjects is there a function the same as “Select Features by Polygon” of ArcMap's tool


I want to know whether there is a function provided by ArcObjects (vb.net) to realize the "Select Features by Polygon" on ArcMap (shown below).

I am using VS 2012 (vb.net) and ArcObjects 10.2.2.


If you want to select features by polygon using ArcObjects, you would typically use a spatial filter, which is very simple to implement. Here's an example in VB.NET, where pPolygon is your polygon object, and pLayer is the layer you wish to select features from:

' create the spatial filter Dim pSpatialFilter As ISpatialFilter = New SpatialFilterClass() pSpatialFilter.Geometry = pPolygon pSpatialFilter.GeometryField = pLayer.FeatureClass.ShapeFieldName pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains ' select features Dim pFeatureSelection As IFeatureSelection pFeatureSelection = pLayer pFeatureSelection.SelectFeatures(pSpatialFilter, esriSelectionResultEnum.esriSelectionResultAdd, False)

If you want to draw the polygon yourself using ArcObjects, then that's a bit of extra work. There are sample functions available to draw a polygon with mouse clicks (just google it), and then use that polygon object as your spatial filter input.