1

I'm trying to run a map algebra expression in a vb.net add-in, and can't seem to get it to work. It's a roving window that interpolates noData areas in a DEM. The expression works in the Python window, and in a Python stand alone script (after replacing the bound raster [inputDEM], with "inputDEM"). In vb it throws a syntax error. Any thoughts?

Thanks so much,

DR

Try
                Dim demPath As String = demLayer.FilePath.Remove((demLayer.FilePath.Length - demLayer.Name.Length), demLayer.Name.Length)
                Dim inputDem As IRasterDataset = OpenRasterDataset(demPath, demLayer.Name)
                Dim mapAlgebra As IMapAlgebraOp = New RasterMapAlgebraOpClass()
                Dim environment As IRasterAnalysisEnvironment = mapAlgebra
                Dim workspaceFactory As IWorkspaceFactory = New RasterWorkspaceFactoryClass()
                environment.OutWorkspace = workspace
                mapAlgebra.BindRaster(inputDem, "inputDEM")
                Dim outputDem As IRaster = mapAlgebra.Execute("Con(IsNull([inputDEM]),FocalStatistics([inputDEM],NbrRectangle(16,16),'MEAN'),[inputDEM])")
                Dim saveDem As ISaveAs2
                saveDem = outputDem
                saveDem.SaveAs("fillGaps", workspace, "GRID")
            Catch ex As Exception
                MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error")
            End Try

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.