Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Using ArcObjects, is there a way to programmatically obtain the "friendly name" for a layer's data type as seen in the ArcMap Source tab for layers in a map document?

e.g.:

  • File System Raster
  • Shapefile Feature Class
  • Tiled Internet Layer

Or is this ArcMap-specific code and not exposed to ArcObjects?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

This information is provided by the INativeType interface. You can access the native type for a given layer's data source as shown below (I hope you dont mind some VBA, should be easy to follow):

Sub DisplayLayerDataTypeString()

  Dim pDoc As IMxDocument
  Dim pLayer As ILayer
  Dim pDataLayer As IDataLayer
  Dim pDataSourceName As IName
  Dim pNativeTypeInfo As INativeTypeInfo
  Dim pNativeType As INativeType

    Set pDoc = Application.Document
    Set pLayer = pDoc.FocusMap.Layer(0)

    If Not TypeOf pLayer Is IDataLayer Then
      Debug.Print "Not a data layer"
      Exit Sub
    End If

    Set pDataLayer = pLayer
    Set pDataSourceName = pDataLayer.DataSourceName

    If Not TypeOf pDataSourceName Is INativeTypeInfo Then
      Debug.Print "Not a native type data source"
      Exit Sub
    End If

    Set pNativeTypeInfo = pDataSourceName
    Set pNativeType = pNativeTypeInfo.NativeType

    Debug.Print pNativeType.Description


End Sub
share|improve this answer
    
+1. Very close, but unfortunately this doesn't seem to work on Mosaic Datasets and Tiled Internet Layers (ArcGIS Online basemaps), and possibly others. The descriptions are also slightly less specific than the ones in ArcMap, e.g. "File System Raster" is a "Raster Dataset". Any other suggestions? –  blah238 Jul 11 '12 at 10:06
    
Interesting.. I was unable to find anything for base map layers, for example. It can really be internal to ArcObjects after all.. –  Petr Krebs Jul 11 '12 at 11:18
    
I could use interface testing for Mosaic Datasets (IMosaicLayer), but I found out that ArcGIS Online tiled basemap layers (like Bing Aerial) implement MapServerLayer but not IMapServerLayer. However I was able to get its CLSID and ProgID: {a4badc1b-ebed-4a29-99dc-c6334de352ad}, esriCarto.InternetTiledLayer.1 –  blah238 Jul 11 '12 at 11:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.