ddoucet20

Selecting Features Within a Polygon [solved]

Discussion created by ddoucet20 on Aug 28, 2017
Latest reply on Sep 1, 2017 by ddoucet20

Hello, I was wondering if I could get some help with this problem.

 

Currently I'm using this line of code to select point features inside of a polygon. 

MapView.Active.SelectFeatures(polygon, SelectionCombinationMethod.Add, true, false);

 

However I noticed it is not very.. accurate? the description for this method is that it selects features that intersect a geometry, however clearly that's not whats happening as the points are outside of the polygon. What would be a functioning equivalent to the geoprocessing tool Select by Location? As the SelectFeatures method is unclear as to what it actually does.

 

Any help would be appreciated.

 

 

------------------------------------------------------------------------------------------------------------------------------------------------------------

 

The solution I found was to use a SpatialQueryFilter (below)

 

SpatialQueryFilter sqf = new SpatialQueryFilter { FilterGeometry = polygon, SpatialRelationship = SpatialRelationship.Contains };

[pointlayer].Select(sqf);

 

Instead of MapView.Active.SelectFeatures(polygon), which doesn't work properly.

Attachments

Outcomes