I have been searching the samples and the API, but so far I have not been able to find any signs on how to make a "Select by Location" in C# With PRO-SDK.
Anyone out there that can point me in the right direction?
Regards
Thanks for the code, it would make more sense if formatted properly.
Based on spatial query selecting multiple features and going through selected features
QueuedTask.Run(() =>
{
using (Geodatabase DMPGeodatabase = new Geodatabase(DMPReadConn))
{
FeatureClass featureClassToBeSelected =
DMPGeodatabase.OpenDataset<FeatureClass>("featureClassToBeSelected");
FeatureClass featureClassSelectionCriteria =
DMPGeodatabase.OpenDataset<FeatureClass>("featureClassSelectionCriteria");
using (RowCursor rowCursor = featureClassSelectionCriteria.Search())
{
while (rowCursor.MoveNext())
{
using (ArcGIS.Core.Data.Row row = rowCursor.Current)
{
if (row["Field"].ToString() == "someAtrribute") //e.g., row[city] = "Chicago"
{
Feature feature = rowCursor.Current as Feature;
Geometry geometry = feature.GetShape(); //Get Chicago's shape point, polygon or line
var spatialQuery = new SpatialQueryFilter() { FilterGeometry = geometry, SpatialRelationship = SpatialRelationship.Intersects };
var selectedFeatures = featureClassToBeSelected.Select(spatialQuery, SelectionType.ObjectID, SelectionOption.Normal); //selected features inside Chicago
using (RowCursor rowCursorPB = selectedFeatures.Search())
{
while (rowCursorPB.MoveNext())
{
using (ArcGIS.Core.Data.Row rowPropBoundsPB = rowCursorPB.Current)
{
//Go through all selected features based on spatial query
//Do something with selected features
}
}
}
}
}
}
}
}
});