Hi,
I want to write a piece of code (ArcObjects 10.3 c#) to check if a layer in table of contents in ArcGIS is raster. Can someone help me please.
Thanks
Masroor
Solved! Go to Solution.
Here's VB.NET code (from an add-in) that will cycle through each layer in your map and do something if it's a raster
Dim pEnumLayers As ESRI.ArcGIS.Carto.IEnumLayer Dim pLayer As ESRI.ArcGIS.Carto.ILayer If My.ArcMap.Document.FocusMap.LayerCount > 0 Then pEnumLayers = My.ArcMap.Document.FocusMap.Layers pLayer = pEnumLayers.Next Do Until pLayer Is Nothing If pLayer.Valid Then If TypeOf pLayer Is ESRI.ArcGIS.Carto.IRasterLayer Then ' do something End If End If pLayer = pEnumLayers.Next Loop End If
Here's VB.NET code (from an add-in) that will cycle through each layer in your map and do something if it's a raster
Dim pEnumLayers As ESRI.ArcGIS.Carto.IEnumLayer Dim pLayer As ESRI.ArcGIS.Carto.ILayer If My.ArcMap.Document.FocusMap.LayerCount > 0 Then pEnumLayers = My.ArcMap.Document.FocusMap.Layers pLayer = pEnumLayers.Next Do Until pLayer Is Nothing If pLayer.Valid Then If TypeOf pLayer Is ESRI.ArcGIS.Carto.IRasterLayer Then ' do something End If End If pLayer = pEnumLayers.Next Loop End If
Hi, first to get the layer index from layer name if that's not already known, using snippet like http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//0049000000ns000000 , then check if it is ESRI.ArcGIS.Carto.IRasterLayer, similar to this snippet http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//004900000076000000
Hope this is what you are asking?