Hi,
Here is a model that calculates a local maximum differential alitudes using a range of neighborhood distances on a digital elevation model.
It uses a small DEM tif file in input (dem25m.tif) that was given to you during the teaching sessions. But you can use any other.
You can switch from extendedMoore
to extendedCircularMoore
by removing comment //
scenario Locmax {
println("Model Locmax find the local maximum slopes at different resolutions")
fix ddem = new D_Dem
fix rcc = new CellCell
rcc.connect(ddem.readAllAltCell)
for (neighborcells : 2..5) {
// neighborhood radius in number of cells
// as the cells resolution is 25m in this model
// 5 cells will make 125m radius for example
rcc.extendedMoore(neighborcells)
// rcc.extendedCircularMoore(neighborcells)
rcc.findlocmax
fix rex = new RasterExport
rex.export(rcc.altCells,"output/localmax_radius"+neighborcells+".tif","EPSG:32740","locmax")
}
println("Done")
}
entity AltCell {
property Cell cell
property Double altitude
property Double locmax
}
relation CellCell<AltCell c1, AltCell c2> {
interaction findlocmax() {
if (c1.altitude > c2.altitude) {
c1.locmax = c1.altitude - c2.altitude
c2.locmax = c2.altitude - c1.altitude
}
else {
c1.locmax = c2.altitude - c1.altitude
c2.locmax = c1.altitude - c2.altitude
}
} agg {
c1.locmax << Max
c2.locmax << Max
}
}
datafacer D_Dem {
data RasterFile("data/dem25m.tif")
match AltCell {
altitude : "0"
}
}
Hope this helps ...