Hyperlink to ArcSDE Raster

Last Modified:06/20/2002

This sample shows how to implement ArcMap hyperlinks from a ArcSDE feature layer to images stored in the same database. It makes use of the Map Control to display the raster on a form.

This sample requires the images to be stored in an embedded raster catalog, a data structure new to ArcGIS at release 8.2. An embedded raster catalog has just one business table and a set of raster tables which can store many ArcSDE rasters.

How to use:
  1. Since the data must all be in an ArcSDE database, there is no test data supplied with this sample. A suggested procedure for organising the data is described below; it will result in a polygon feature class, with two of the polygons having a value in their PICTURE field pointing to an image stored with ArcSDE.
  2. Use the ArcCatalog VBA script below to load two photographic images into an ArcSDE embedded raster catalog. You will need to edit the script to provide your ArcSDE connection details, and also the folder where your input images reside. The result will be a new embedded raster catalog table called PICTURECATALOG. Preview the table details in ArcCatalog.
  3. Take the USA shapefile in the Developer Samples data and load it into your ArcSDE geodatabase. Register the new dataset as versioned.
  4. Add a text field called PICTURE to the USA feature class.
  5. Edit two of the polygons, perhaps California and Oregon, to have a value for the PICTURE field equivalent to the names of the images in the PICTURECATALOG table. Note that a source image called myphoto.jpg is likely to be named myphoto_jpg in the table.
  6. Register the DLL of the supplied Visual Basic project, then in the ArcMap VBA environment, use Tools/References to browse to the DLL and check 'DbRasterHotlink'.
  7. In the ArcMap VBA environment add the Hotlink.bas module file, by right clicking on the Project document and choosing Import File.
  8. Add the USA ArcSDE layer to ArcMap. Go to the Display Tab of the layer properties and turn Hyperlinks on. Set the field to PICTURE and the macro to Project.Hotlink.ShowDbRaster.
  9. Use the ArcMap Hyperlink tool to click on California or Oregon. The associated image should appear in a window.

Public Sub Hyperlink2SDERasterLoad()
  Dim sDir As String, sServer As String, sInstance As String, _
      sDB As String, sUser As String, sPasswd As String, sSDECatalog As String
  sDir = "D:\Stuff\Pictures\Test" ' the directory where the input rasters reside
  sSDECatalog = "PictureCatalog"  ' output embedded raster catalog name
  sServer = "cuillin"             ' ArcSDE connection info
  sInstance = "esri_sde"          ' ArcSDE connection info
  sUser = "jim"                   ' ArcSDE connection info
  sPasswd = "jim"                 ' ArcSDE connection info
  sDB = ""                        ' ArcSDE connection info
  Dim pSDEConn As IRasterSdeConnection2
  Dim pSDEStorage As IRasterSdeStorage2
  Dim pSDEOp As IRasterSdeServerOperation2
  Dim pSDECatalog As IRasterSdeCatalog
  Dim pRasterWsFact As IWorkspaceFactory
  Dim pRasterWs As IWorkspace
  Dim pEnumDataset As IEnumDataset
  Dim pRasterDs As IDataset
  Dim pGeoDs As IGeoDataset
  Dim i As Integer
  Dim sRaster As String
  ' Get all the datasets in the input directory
  Set pRasterWsFact = New RasterWorkspaceFactory
  Set pRasterWs = pRasterWsFact.OpenFromFile(sDir, 0)
  Set pEnumDataset = pRasterWs.Datasets(esriDTRasterDataset)

  ' Initialize RasterSDELoader
  Set pSDEConn = New RasterSdeLoader
  ' Make connection
  pSDEConn.ServerName = sServer
  pSDEConn.Instance = sInstance
  pSDEConn.Database = sDB
  pSDEConn.UserName = sUser
  pSDEConn.password = sPasswd
  ' Set raster catalog name
  Set pSDECatalog = pSDEConn
  pSDECatalog.CatalogName = sSDECatalog
  ' Loop through all the datasets, create the catalog for the first time, and insert afterwards.
  Set pRasterDs = pEnumDataset.Next
  Do While Not pRasterDs Is Nothing
    sRaster = pRasterDs.Name
    pSDEConn.InputRasterName = sDir & "\" & sRaster
    sRaster = Replace(sRaster, ".", "_") ' replace "." with "_"
    pSDECatalog.RasterName = sRaster
    ' Set storage parameters and spatial reference
    Set pSDEStorage = pSDEConn
    If i = 0 Then
      Set pGeoDs = pRasterDs
      Set pSDEStorage.SpatialReference = pGeoDs.SpatialReference
    End If

    ' Set compression (LZ77), tilesize and pyramidding
    pSDEStorage.CompressionType = esriRasterSdeCompressionTypeRunLength
    pSDEStorage.TileHeight = 128
    pSDEStorage.TileWidth = 128
    pSDEStorage.PyramidOption = esriRasterSdePyramidDonotBuild
    ' Start loading
    Set pSDEOp = pSDEConn
    If i = 0 Then
    End If
    ' Calculate stats (optional)
    Set pRasterDs = pEnumDataset.Next
    i = 1
End Sub
Application: ArcMap

Requires: ArcSDE database

Minimum ArcGIS Version Required: 8.2

Difficulty: Intermediate

Visual Basic
File Description
Hotlink.bas VBA module holding the hyperlink script
DbRaster.frm VB Form for displaying the image
RasterHotlink.cls Class controlling the form
DbRasterHotlink.vbp Visual Basic project file

Key CoClasses: HyperLink, RasterDataSet, RasterLayer, MapControl
Key Interfaces: IHyperLink, IRasterDataSet, IRasterLayer, IDataSetName, IDataSet