Hi,
I would like to load the lyrx file in memory (i.e. without loading it on screen) in ArcGIS Pro and use it to do an intersect (or a spatial search) with a layer that is already loaded in Pro. Is that possible? We used to do that in ArcMap / ArcObjects where we read the lyr file into a ILayer object. This ILayer object is only in memory, not on the ArcMap screen.
In Pro, we can call LayerFactory.Instance.CreateLayer() to create a Layer object from a lyr file, but the layer will be loaded on screen.
Uri uri = new Uri(sTempLayerFilePath);
pLayer = LayerFactory.Instance.CreateLayer(uri, _pMap);
> Do you have plan to give option to CreateLayer() not loading layer into Table of Content?
Thanks
Hi Joon,
If you use geoprocessing for your operation you do not need to create layer. Use Geoprocessing.MakeValueArray to construct parameters list. All parameters of Geoprocessing.MakeValueArray are object type so you can put featurelayer, featureclass or string path to your feature class. It will recognize automatically parameter type and will read required information.
But, isn't true that, even if I use geoprocessing to run the intersect, I need to load the output feature class and read the intersect results? That means the output layer will be seen on screen in Pro. But, in the ArcObjects world, I can do an intersect and read the results via ILayer, IFeatureCursor, and IFeature, without loading anything on screen in ArcMap.
Hi,
ArcGIS Pro geoprocessing has the same feature as ArcObjects does. Do not use flags GPExecuteToolFlags.AddOutputsToMap or GPExecuteToolFlags.Default and geoprocessing results will not be added
to map. More information here:
https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Geoprocessing
Without adding the layer to the Pro screen, how do you read the intersect results? Thanks.
Hi Vivien,
You must set output path of your results. I do not know which exactly geoprocessing tool you are going to use, but I will show you on Spatial Analyst Raster Calculator example:
private static bool ExecuteRasterCalculator(string sExpression, string sOutRaster, Envelope pExtent, string sWorkspace, string sMaskRaster)
{
try
{
var gpresult1 = Task.Run(() =>
{
var parameters = Geoprocessing.MakeValueArray(sExpression, sOutRaster);
IReadOnlyList<KeyValuePair<string, string>> environments;
environments = Geoprocessing.MakeEnvironmentArray(mask: sMaskRaster, extent: pExtent, workspace: sWorkspace);
return Geoprocessing.ExecuteToolAsync("RasterCalculator_sa", parameters, environments,
CancelableProgressor.None, GPExecuteToolFlags.AddToHistory);
});
return !gpresult1.Result.IsFailed;
}
catch (Exception ex)
{
throw;
}
}
Result raster will be stored on path sOutRaster. Geoprocessing.MakeValueArray parameters count and sequence depends on geoprocessing tool. For order and parameters look into your tool description