PROBLEM

Raster layer result from ISurfaceOp:: Curvature method displays blank in ArcMap

Last Published: April 25, 2020

Description

When the parameters for creating a plan and a profile are set to true in the
ISurfaceOp::Curvature method, the output is a raster that references three raster datasets. If only one of the plan or profile parameters is set to true, the output is a raster that references two raster datasets. If the output raster is added directly to ArcMap, it displays blank.

Cause

This is a known issue with ArcGIS 8.1.

Solution or Workaround

To add the output from the Curvature function correctly, add each band of the raster separately as a layer to ArcMap.

  • Run the Curvature function.

    Sub CreateCurvature()
    ' Get the Map from the Map Document
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    ' Get input raster from first layer in ArcMap
    Dim pRasterLy As IRasterLayer
    Dim pLy As ILayer
    Dim pInRaster As IGeoDataset
    Set pLy = pMap.Layer(0)
    If Not TypeOf pLy Is IRasterLayer Then Exit Sub
    Set pRasterLy = pLy
    Set pInRaster = pRasterLy.Raster

    ' Create Surface Op
    Dim pSurOp As ISurfaceOp
    Set pSurOp = New RasterSurfaceOp

    ' Set output workspace
    Dim pEnv As IRasterAnalysisEnvironment
    Set pEnv = pSurOp
    Dim pWS As IWorkspace
    Dim pWSF As IWorkspaceFactory
    Set pWSF = New RasterWorkspaceFactory
    Set pWS = pWSF.OpenFromFile("c:\temp", 0)
    Set pEnv.OutWorkspace = pWS

    'Run the Curvature function
    Dim pOutRaster As IGeoDataset
    Set pOutRaster = pSurOp.Curvature(pInRaster, True, True)

    'Call AddResultOfCurvatureAsLayer subroutine
    AddResultOfCurvatureAsLayer pOutRaster, pMap

    End Sub

  • Apply the following subroutine to the result from the Curvature operation.

    Code:
    Sub AddResultOfCurvatureAsLayer(pResultOfCurvature As IRaster, pMap As IMap)
    ' pResultOfCurvature: the output from Curvature operation
    ' pMap: the Map object obtained from ThisDocument

    Dim pRasBandC As IrasterBandCollection
    ' QI IRasterBandCollection interface
    Set pRasBandC = pResultOfCurvature
    Dim pRasBand As IRasterBand
    Dim pOutRasterDS As IRasterDataset
    Dim pOutRaster As IRaster
    Dim pNewLayer As IRasterLayer
    Dim BandCount, I As Integer
    ' Get the number of raster bands
    BandCount = pRasBandC.Count
    ' Add each band as a layer to ArcMap
    For I = 0 To BandCount - 1
    Set pRasBand = pRasBandC.Item(I)
    Set pOutRasterDS = pRasBand.RasterDataset
    Set pOutRaster = pOutRasterDS.CreateDefaultRaster
    Set pNewLayer = New RasterLayer
    pNewLayer.CreateFromRaster pOutRaster
    pMap.AddLayer pNewLayer
    Next I
    End Sub

Article ID:000003470

Software:
  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options