pmbalda

Create Raster Dataset no longer works

Discussion created by pmbalda on Jan 6, 2011
Latest reply on Feb 7, 2011 by erikadade
It was working just fine until I upgraded to VS 2010. I'm now in VS 2010 Framework 3.5 ArcMap 9.3.1. I'm sorry to do this, but can someone look at it and tell me what's changed/I'm doing wrong? The value for the raster cells only ever comes out to 32767 (PTShort).

Dim pEnv As IEnvelope = m_pGlobals.Envelopes.Extent
Dim pOrigin_BLC As IPoint = New Point
pOrigin_BLC.PutCoords(CDbl(pEnv.LowerLeft.X), CDbl(pEnv.LowerLeft.Y))

        ' Create the dataset
Dim pWS As IRasterWorkspace2 = CreateRasterWorkspace(sCurrentDirectory)
If (pWS Is Nothing) Then
          MsgBox("Raster workspace not created; exiting")
          g_bExit = True
          Return
End If
pRDS = pWS.CreateRasterDataset(sFileName, "GRID", pOrigin_BLC, _
                                               lXRes, lYRes, g_pModel.MperPix, _
                                               g_pModel.MperPix, 1, rstPixelType.PT_SHORT, _
                                               pGeoDataset.SpatialReference, True)
      
        ' QI for IRawPixels and IRasterProps
Dim pBands As IRasterBandCollection = pRDS
Dim pRawpixel As IRawPixels = pBands.Item(0)
Dim pRasterProps As IRasterProps = pRawpixel

        ' Create pixelblock
pSize = New DblPnt
pSize.SetCoords(CDbl(pRasterProps.Width), CDbl(pRasterProps.Height))
pPixelBlock = pRawpixel.CreatePixelBlock(pSize)

        ' Read pixelblock
pTLCPoint = New DblPnt
pTLCPoint.SetCoords(0, 0)
pRawpixel.Read(pTLCPoint, pPixelBlock)

        ' Get pixeldata array
pPixelData = pPixelBlock.PixelDataByRef(0)

For lX = 0 To g_lXRes - 1
   For lY = 0 To g_lYRes - 1
            pPixelData(lX, lY) = 5 'arrData(lX, lY)
   Next lY
Next lX

        'write the pixel block
pCache = pRawpixel.AcquireCache
pRawpixel.Write(pTLCPoint, pPixelBlock)
pRawpixel.ReturnCache(pCache)

        'Create a raster layer and add it to the map
BuildRasterAttributeTable(pRDS, Nothing)

BuildRasterAttributeTable does nothing.

Paige

Outcomes