I'm trying to select a county feature from a nationwide counties layer using Geoprocessor's managed SelectLayerByLocation coclass:
internal static void GetCountyName(IPoint centerpoint, out string countyName)
{
Geoprocessor gp = new Geoprocessor();
SelectLayerByLocation selectByLocation = new SelectLayerByLocation();
selectByLocation.in_layer = countiesLayer; //IFeatureLayer in mxd
selectByLocation.select_features = centerpoint; //cause of error
try
{
gp.Execute(selectByLocation, null);
//countyName will be retrieved from value of selected feature
}
catch (Exception)
{
string message = "";
for (int i = 0; i < gp.MessageCount; i++)
message += gp.GetMessage(i) + "\n";
MessageBox.Show(message);
}
}
The MessageBox showed me this:
I found here that the "select_features" parameter requires either a FeatureLayer or FeatureClass:
But I know that ArcPy has PointGeometry specifically so that you don't have to create a stored feature class just to use it as a geoprocessing parameter:
In many geoprocessing workflows, you may need to run a specific operation using coordinate and geometry information but don't necessarily want to go through the process of creating a new (temporary) feature class, populating the feature class with cursors, using the feature class, then deleting the temporary feature class. Geometry objects can be used instead for both input and output to make geoprocessing easier.
Is there an option like this for ArcObjects?