Need to check layers type

2323
6
12-23-2013 11:06 PM
VeronikaLem
New Contributor
I have list of layers opened in ArcMap.
1. I need to check which layer is Point Layer (not Line or Polygon)... now i use
if (layer is IFeatureClass) but of course it add line and polygon layers too

2. And i need to check which layer is Geostatistical Layer and just it...now i use
if (layer is IRasterLayer) but its have many varients and i need just geostatistical layer

Can anybody help me (better with examples on c#)?:)
0 Kudos
6 Replies
KenBuja
MVP Esteemed Contributor
This code, taken from an add-in (which is why it uses My.ArcMap.Document), will loop through all the layers in your document and return only point layers

ESRI.ArcGIS.Carto.ILayer2 pLayer = default(ESRI.ArcGIS.Carto.ILayer2);
ESRI.ArcGIS.Carto.IFeatureLayer2 pFLayer = default(ESRI.ArcGIS.Carto.IFeatureLayer2);
ESRI.ArcGIS.Carto.IEnumLayer pEnumLayers = default(ESRI.ArcGIS.Carto.IEnumLayer);

if (My.ArcMap.Document.FocusMap.LayerCount > 0) {
    pEnumLayers = My.ArcMap.Document.FocusMap.Layers;
    pLayer = pEnumLayers.Next;
    while (!(pLayer == null)) {
        if (pLayer is ESRI.ArcGIS.Carto.IFeatureLayer & !pLayer is ESRI.ArcGIS.Carto.IGroupLayer & pLayer.Valid) {
            pFLayer = new ESRI.ArcGIS.Carto.FeatureLayer();
            pFLayer = pLayer;
            if (pFLayer.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) {
                //a point layer
            }
        }
        pLayer = pEnumLayers.Next;
    }

}
VeronikaLem
New Contributor
Thank you!
and what about geostatistical layer?
0 Kudos
KenBuja
MVP Esteemed Contributor
I'm not aware of a layer type specific to GeoStatistics
0 Kudos
KenBuja
MVP Esteemed Contributor
It seems that geostatistical layers are really just referencing the source of their input layers?

http://resources.arcgis.com/en/help/main/10.2/index.html#/What_is_a_geostatistical_layer/00310000005...
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/esriDatasetType_Constant...

I played around with it briefly and it seems to return 5-esriDTFeatureClass for some outputs, and 12-esriDTRasterDataset for other Geostatistical Layers.

There must be some way to identify geostatistical layers though, obviously you can find a specific layer using the name in the TOC, but I'm not sure how you could identify just those layers created using geostatistical analyst.  Sounds like a question for an MVP or support...


However, a GeoStatistical Analyst layer does have some unique aspects, with additional information in the TOC and a different context menu, so there must be some way of differentiating it. I just can't find any coclasses that implement ILayer which would represent a GeoStatistical layer.
VeronikaLem
New Contributor
Thank you for yr answers. Will try to do smth to get what i need, or will write to esri support:)
0 Kudos
LeoDonahue
Occasional Contributor III
com.esri.arcgis.geostatisticalanalyst.GPGALayer

The Interface to this class would be IGPLayer or IDEGeoDataset.