Berechnung mit bufferbyrise_ver3

Hallo,

habe ein Problem bei der Berechnung von Überschwemmungsflächen. Das Tool "bufferbyrise_ver3" liefert dabei gute Werte. Leider rechnet es nur mit ganzen Zahlen, es ist also egal ob ich mit 1m oder 1,5m Wassertiefe rechne. Die Überschwemmungsfläche ist in beiden Fällen gleich groß.
Kann mir jemand sagen, wie ich das Tool so umschreiben kann, daß es auch mit Dezimalzahlen rechnet?? - ich habe leider von der Avenueprogrammierung keine Ahnung.

Danke für Eure Hilfe!

So sieht das Script aus:

test=Extension.Find("Spatial Analyst")
if (test=NIL) then
msgbox.error("You must have the spatial analyst extension loaded","elevation buffer")
return(nil)
end

theProject = av.getProject
theView = av.GetActiveDoc
theDisplay = theView.GetDisplay
myPrj = prj.makeNull
aPrj = theView.GetProjection
ThemeList = theView.getThemes

'set extent and cell size for conversion if not already set
ae = theView.GetExtension(AnalysisEnvironment)
box = Rect.Make(0@0,1@1)
cellSize = 1
if ((ae.GetExtent(box) <> #ANALYSISENV_VALUE) or (ae.GetCellSize(cellSize) <> #ANALYSISENV_VALUE)) then
ce = AnalysisPropertiesDialog.Show(theView,TRUE,"Analysis Extent")
if (ce = NIL) then
return NIL
end
ce.GetCellSize(cellSize)
ce.GetExtent(box)
end

ae.Activate

theStreams = List.Make
for each t in ThemeList
if ( t.Is(Ftheme)) then
theStreams.Add(t)
end
end

'user needs to select a grid representing elevation

theTopoGrids = List.Make
for each t in ThemeList
if ( t.Is(Gtheme)) then
theTopoGrids.Add(t)
end
end

aGrid2 = MsgBox.ListAsString (theTopoGrids, "Select the elevation GRID","elevation grid" )
if (aGrid2 = NIL) then
return NIL
end

'is there a stream that the user wants to use? if not, a new one will be created

streamsOrNot = MsgBox.YesNo ("Do you have a stream theme?" +NL+ "if no, one will be created now" +NL+ "WARNING - stream development may take a long time", "stream theme?", true)

if (streamsOrNot = FALSE)

then

'myStreamThemeName = msgBox.input("stream theme", "what do you want to name your stream shapefile?", "streams.shp")
myFileName = FileDialog.Put (((theProject.GetWorkDir).asString + "/stream_.shp").asFilename , "*.shp", "what do you want to name your stream shapefile?")

if (myFileName = NIL)
then return NIL
end

' Fill script

elevGrid = aGrid2.GetGrid
sinkCount = 0
numSinks = 0
while (TRUE)
flowDirGrid = elevGrid.FlowDirection(FALSE)
sinkGrid = flowDirGrid.Sink
if (sinkGrid.GetVTab = NIL) then
' check for errors
if (sinkGrid.HasError) then return NIL end
sinkGrid.BuildVAT
end
' check for errors
if (sinkGrid.HasError) then return NIL end
if (sinkGrid.GetVTab <> NIL) then
theVTab = sinkGrid.GetVTab
numClass = theVTab.GetNumRecords
newSinkCount = theVTab.ReturnValue(theVTab.FindField("Count"),0)
else
numClass = 0
newSinkCount = 0
end
if (numClass < 1) then
break
elseif ((numSinks = numClass) and (sinkCount = newSinkCount)) then
break
end
waterGrid = flowDirGrid.Watershed(sinkGrid)
zonalFillGrid = waterGrid.ZonalFill(elevGrid)
fillGrid = (elevGrid < (zonalFillGrid.IsNull.Con(0.AsGrid,zonalFillGrid))).Con(zonalFillGrid, elevGrid)
elevGrid = fillGrid
numSinks = numClass
sinkCount = newSinkCount
end

'make flow direction grid

dirGrid = elevGrid.FlowDirection (false)

'make flow accumulation grid

accGrid = dirGrid.FlowAccumulation (NIL)

' make stream grid

MinAccForStream = MsgBox.Input ("What are the minimum number of accumulated cells" +NL+ "required to generate a stream?", "stream cells", "5000")
if (MinAccForStream = NIL) then
return NIL
end

CellAmount = MinAccForStream.AsNumber

streamGrid = accGrid < CellAmount

myExtent = streamGrid.getExtent
myCellSize = streamGrid.getCellSize

RCgrid = streamGrid.setNull(1.asGrid)
'RCGTheme = GTheme.make(RCGrid)
'theView.addtheme(RCGTheme)

' make a line theme for the streams in the reclassfied stream grid

'myName = myStreamThemeName
'myFileName = myName.asFileName

anFtab = RCgrid.StreamToPolyLineFTab (myFileName, dirGrid, true, myPrj)

myFTheme2 = FTheme.make(anFtab)

t = myFTheme2

else

t = MsgBox.ListAsString(theStreams, "Select the STREAM THEME to buffer by elevation", "Stream theme" )
if (t = NIL) then
return NIL
end

end

anFTab = t.GetFTab
anFTab.StartEditingWithRecovery
myField = Field.Make ("gridval",#FIELD_DECIMAL,1,0)
myList = {myField}
anFTab.AddFields (myList)
anFTab.StopEditingWithRecovery(true)

AttOrNot = MsgBox.YesNo ("Do you want to buffer by a constant" +NL+ "or an attribute value from the stream shape?" +NL+ "YES = constant NO = attribute", "CONSTANT or ATTRIBUTE?", true)
if (AttOrNot = TRUE) then

' select buffer area and convert to number

UserValue = MsgBox.Input ("Enter an elevation buffer value", "Elevation Buffer", "0")
if (UserValue = NIL) then
return NIL
end

BoxNumber = UserValue.AsNumber

else

BufferFieldsList = anFtab.getFields
myBufferField = MsgBox.List (BufferFieldsList, "Choose the field that represents buffer height", "Buffer Attribute")
if (myBufferField = NIL)
then return NIL
end

'''''end

' convert selected features of a FTheme to Grid

' get class name of doc to see if script is running from a view or scene
theDocName = theView.GetClass.GetClassName

aGridAtt = Grid.MakeFromFTab(anFtab, aPrj, myBufferField, {cellSize, Box})
aGridAttInt = aGridAtt.int
BoxNumber = aGridAttInt.EucAllocation(NIL, NIL, NIL)

end

' convert feature theme to grid
aGrid1 = Grid.MakeFromFTab(anFTab,aPrj,myField,{cellSize, Box})
if (aGrid1.HasError) then
MsgBox.Error(t.GetName ++ "could not be converted to a grid","Conversion Error")
return NIL
end

' calculate value of new grid
aGrid3 = aGrid2.getGrid
aGrid4 = aGrid3 + aGrid1
aGrid5 = aGrid4.Int

' check if output is ok
if (aGrid5.HasError) then
return NIL
end

' create proximity map
EucGrid = aGrid5.EucAllocation(NIL, NIL, NIL)

' calculate elevation change grid
aGrid6 = aGrid3 - EucGrid
aGrid7 = aGrid6.Int

' make final calculation by selecting area of elevation change that is less than or equal to the user input

aGrid8 = aGrid7 <= BoxNumber

' relcassify final grid so that 1 = the value selected by the user, and 0 = noData

a2 = classification.Make (0, 0)
a2.setLabel ("noData")

b2 = classification.Make (1, 1)
b2.setLabel (1.asString)

classList2 = list.make
classList2 = {a2, b2}

RCgrid2 = aGrid8.ReclassByClassList ("value", ClassList2, TRUE)
aGrid9 = RCgrid2 * BoxNumber

myBuffPolyFileName = FileDialog.Put (("elevbuff_.shp").asFilename , "*.shp", "what do you want to name your elevation buffer?")

'myBuffPolyName = msgBox.input("buffer name", "what do you want to name your elevation buffer?", "elevbuff.shp")
if (myBuffPolyFileName = NIL)
then return NIL
end

myBuffPolyFileName2 = ("a_" + (myBuffPolyFileName.getBaseName)).asFilename

myBuffPoly = aGrid9.AsPolygonFTab (myBuffPolyFileName, TRUE, myPrj)

theFinalFTheme = FTheme.Make(myBuffPoly)
theFinalFTab = theFinalFTheme.getFTab
theFinalFTab.SelectByFTab (anFTab, #FTAB_RELTYPE_INTERSECTS , 0, #VTAB_SELTYPE_NEW )

theFinalFTab2 = theFinalFTheme.ExportToFTab (myBuffPolyFileName2)
theFinalFTheme2 = FTheme.Make(theFinalFTab2)

theFinalGrid2 = Grid.MakeFromFTab (theFinalFTab2, aPrj, theFinalFTab2.findField("gridcode"), {cellsize, box})
theFinalGTheme2 = GTheme.make(theFinalGrid2)
theFinalGTheme2.setName("elevbuff")
theView.addTheme(theFinalGTheme2)

'''''myBuffPolyTheme = myBuffPoly

anFTab.StartEditingWithRecovery
anFTab.RemoveFields(myList)
anFTab.StopEditingWithRecovery(true)

theView.AddTheme(theFinalFTheme2)
Hallo Tobias,

kannst du die Quelle des Scripts benennen?

Andreas
Hallo Andreas,

das Sript habe ich bei ESRI runtergeladen.

Tobias
Kleine Korrektur:
Das Skript heißt:

Buffer by Elevation Change ver.3

und nicht Buffer by rise (so wird es nur im Quellcode genannt!)

Gruß Tobias