Search in sources :

Example 1 with OmsGradient

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);
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) OmsGradient(org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient)

Example 2 with OmsGradient

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);
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) OmsGradient(org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient)

Example 3 with OmsGradient

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);
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) OmsGradient(org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient)

Example 4 with OmsGradient

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);
}
Also used : OmsGradient(org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient) Execute(oms3.annotations.Execute)

Example 5 with OmsGradient

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());
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) WritableRandomIter(javax.media.jai.iterator.WritableRandomIter) WritableRaster(java.awt.image.WritableRaster) RegionMap(org.hortonmachine.gears.utils.RegionMap) RandomIter(javax.media.jai.iterator.RandomIter) WritableRandomIter(javax.media.jai.iterator.WritableRandomIter) RenderedImage(java.awt.image.RenderedImage) OmsGradient(org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient) Execute(oms3.annotations.Execute)

Aggregations

OmsGradient (org.hortonmachine.hmachine.modules.geomorphology.gradient.OmsGradient)6 GridCoverage2D (org.geotools.coverage.grid.GridCoverage2D)5 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)3 Execute (oms3.annotations.Execute)2 RenderedImage (java.awt.image.RenderedImage)1 WritableRaster (java.awt.image.WritableRaster)1 RandomIter (javax.media.jai.iterator.RandomIter)1 WritableRandomIter (javax.media.jai.iterator.WritableRandomIter)1 OmsCutOut (org.hortonmachine.gears.modules.r.cutout.OmsCutOut)1 RegionMap (org.hortonmachine.gears.utils.RegionMap)1 OmsRescaledDistance (org.hortonmachine.hmachine.modules.basin.rescaleddistance.OmsRescaledDistance)1 OmsTopIndex (org.hortonmachine.hmachine.modules.basin.topindex.OmsTopIndex)1 OmsDePitter (org.hortonmachine.hmachine.modules.demmanipulation.pitfiller.OmsDePitter)1 OmsExtractBasin (org.hortonmachine.hmachine.modules.demmanipulation.wateroutlet.OmsExtractBasin)1 OmsAb (org.hortonmachine.hmachine.modules.geomorphology.ab.OmsAb)1 OmsCurvatures (org.hortonmachine.hmachine.modules.geomorphology.curvatures.OmsCurvatures)1 OmsDrainDir (org.hortonmachine.hmachine.modules.geomorphology.draindir.OmsDrainDir)1 OmsExtractNetwork (org.hortonmachine.hmachine.modules.network.extractnetwork.OmsExtractNetwork)1