use of org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient in project hortonmachine by TheHortonMachine.
the class TestGradient method testGradient.
public void testGradient() throws Exception {
HashMap<String, Double> envelopeParams = HMTestMaps.getEnvelopeparams();
CoordinateReferenceSystem crs = HMTestMaps.getCrs();
double[][] pitData = HMTestMaps.pitData;
GridCoverage2D pitfillerCoverage = CoverageUtilities.buildCoverage("elevation", pitData, envelopeParams, crs, true);
OmsGradient gradient = new OmsGradient();
gradient.inElev = pitfillerCoverage;
gradient.pm = pm;
gradient.process();
GridCoverage2D gradientCoverage = gradient.outSlope;
checkMatrixEqual(gradientCoverage.getRenderedImage(), HMTestMaps.gradientData, 0.01);
}
use of org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient in project hortonmachine by TheHortonMachine.
the class TestGradient method testGradientHorn.
public void testGradientHorn() throws Exception {
HashMap<String, Double> envelopeParams = HMTestMaps.getEnvelopeparams();
CoordinateReferenceSystem crs = HMTestMaps.getCrs();
double[][] pitData = HMTestMaps.pitData;
GridCoverage2D pitfillerCoverage = CoverageUtilities.buildCoverage("elevation", pitData, envelopeParams, crs, true);
OmsGradient gradient = new OmsGradient();
gradient.inElev = pitfillerCoverage;
gradient.pm = pm;
gradient.pMode = Variables.HORN;
gradient.process();
GridCoverage2D gradientCoverage = gradient.outSlope;
checkMatrixEqual(gradientCoverage.getRenderedImage(), HMTestMaps.gradientHornData, 0.01);
}
use of org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient in project hortonmachine by TheHortonMachine.
the class TestGradient method testGradientEvans.
public void testGradientEvans() throws Exception {
HashMap<String, Double> envelopeParams = HMTestMaps.getEnvelopeparams();
CoordinateReferenceSystem crs = HMTestMaps.getCrs();
double[][] pitData = HMTestMaps.pitData;
GridCoverage2D pitfillerCoverage = CoverageUtilities.buildCoverage("elevation", pitData, envelopeParams, crs, true);
OmsGradient gradient = new OmsGradient();
gradient.inElev = pitfillerCoverage;
gradient.pm = pm;
gradient.pMode = Variables.EVANS;
gradient.process();
GridCoverage2D gradientCoverage = gradient.outSlope;
checkMatrixEqual(gradientCoverage.getRenderedImage(), HMTestMaps.gradientEvansData, 0.01);
}
use of org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient in project hortonmachine by TheHortonMachine.
the class Gradient method process.
@Execute
public void process() throws Exception {
OmsGradient gradient = new OmsGradient();
gradient.inElev = getRaster(inElev);
gradient.pMode = pMode;
gradient.doDegrees = doDegrees;
gradient.pm = pm;
gradient.doProcess = doProcess;
gradient.doReset = doReset;
gradient.process();
dumpRaster(gradient.outSlope, outSlope);
}
use of org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient in project hortonmachine by TheHortonMachine.
the class OmsDebrisTriggerCnr method process.
@Execute
public void process() throws Exception {
checkNull(inElev, inNet, inTca);
// calculate gradient map degrees
OmsGradient gradient = new OmsGradient();
gradient.inElev = inElev;
gradient.pMode = Variables.FINITE_DIFFERENCES;
gradient.doDegrees = true;
gradient.pm = pm;
gradient.process();
GridCoverage2D gradientCoverageDeg = gradient.outSlope;
// calculate gradient map %
gradient = new OmsGradient();
gradient.inElev = inElev;
gradient.pMode = Variables.FINITE_DIFFERENCES;
gradient.doDegrees = false;
gradient.pm = pm;
gradient.process();
GridCoverage2D gradientCoverageTan = gradient.outSlope;
// ritaglio della mappa di gradient lungo il reticolo
// idrografico ed estrazione delle sole celle con
// * pendenza minore di 38 gradi
// * area cumulata minore di 10 km2
RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inElev);
int cols = regionMap.getCols();
int rows = regionMap.getRows();
double xres = regionMap.getXres();
double yres = regionMap.getYres();
RenderedImage netRI = inNet.getRenderedImage();
RandomIter netIter = RandomIterFactory.create(netRI, null);
RenderedImage tcaRI = inTca.getRenderedImage();
RandomIter tcaIter = RandomIterFactory.create(tcaRI, null);
RenderedImage gradientDegRI = gradientCoverageDeg.getRenderedImage();
RandomIter gradientDegIter = RandomIterFactory.create(gradientDegRI, null);
RenderedImage gradientTanRI = gradientCoverageTan.getRenderedImage();
RandomIter gradientTanIter = RandomIterFactory.create(gradientTanRI, null);
WritableRaster outputWR = CoverageUtilities.createWritableRaster(cols, rows, null, null, HMConstants.doubleNovalue);
WritableRandomIter outputIter = RandomIterFactory.createWritable(outputWR, null);
pm.beginTask("Extracting trigger points...", cols);
for (int r = 0; r < rows; r++) {
for (int c = 0; c < cols; c++) {
double net = netIter.getSampleDouble(c, r, 0);
// all only along the network
if (!isNovalue(net)) {
double tca = tcaIter.getSampleDouble(c, r, 0);
// tca in km2 along the net
double tcaKm2 = tca * xres * yres / 1000000;
// gradient in degrees along the net
double gradientDeg = gradientDegIter.getSampleDouble(c, r, 0);
// gradient in tan along the net
double gradientTan = gradientTanIter.getSampleDouble(c, r, 0);
/*
* calculate the trigger threshold:
*
* S = 0.32 * A^-0.2
* where:
* S = gradient in m/m
* A = tca in km2
*/
double triggerThreshold = 0.32 * pow(tcaKm2, -0.2);
if (//
gradientTan > triggerThreshold && //
gradientDeg < pGradthres && tcaKm2 < pTcathres) {
// we have a trigger point
outputIter.setSample(c, r, 0, triggerThreshold);
}
}
}
pm.worked(1);
}
pm.done();
outTriggers = CoverageUtilities.buildCoverage("triggers", outputWR, regionMap, inElev.getCoordinateReferenceSystem());
}
Aggregations