Search in sources :

Example 1 with OmsRasterReader

use of org.hortonmachine.gears.io.rasterreader.OmsRasterReader in project hortonmachine by TheHortonMachine.

the class HMModel method getRaster.

/**
 * Fast default reading of raster from definition.
 *
 * <p>If the source format is not supported, and {@link Exception} is thrown.</p>
 * <p>If the source is <code>null</code>, null will be returned.</p>
 *
 * @param source the definition for the raster source.
 * @return the read {@link GridCoverage2D}.
 * @throws Exception
 */
public GridCoverage2D getRaster(String source) throws Exception {
    if (source == null || source.trim().length() == 0)
        return null;
    OmsRasterReader reader = new OmsRasterReader();
    reader.pm = pm;
    reader.file = source;
    reader.process();
    GridCoverage2D geodata = reader.outRaster;
    return geodata;
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) OmsRasterReader(org.hortonmachine.gears.io.rasterreader.OmsRasterReader)

Example 2 with OmsRasterReader

use of org.hortonmachine.gears.io.rasterreader.OmsRasterReader in project hortonmachine by TheHortonMachine.

the class RasterReader method process.

@Execute
public void process() throws Exception {
    OmsRasterReader rasterreader = new OmsRasterReader();
    rasterreader.file = file;
    rasterreader.pNorth = pNorth;
    rasterreader.pSouth = pSouth;
    rasterreader.pWest = pWest;
    rasterreader.pEast = pEast;
    rasterreader.pXres = pXres;
    rasterreader.pYres = pYres;
    rasterreader.pRows = pRows;
    rasterreader.pCols = pCols;
    rasterreader.doEnvelope = doEnvelope;
    rasterreader.pm = pm;
    rasterreader.doProcess = doProcess;
    rasterreader.doReset = doReset;
    rasterreader.process();
    outRaster = rasterreader.outRaster;
    originalEnvelope = rasterreader.originalEnvelope;
}
Also used : OmsRasterReader(org.hortonmachine.gears.io.rasterreader.OmsRasterReader) Execute(oms3.annotations.Execute)

Example 3 with OmsRasterReader

use of org.hortonmachine.gears.io.rasterreader.OmsRasterReader in project hortonmachine by TheHortonMachine.

the class TestRasterReader method testRasterReaderResOnly.

public void testRasterReaderResOnly() throws Exception {
    double[][] mapData1 = new double[][] { // 
    { -9999.0, 850.0, 900.0, 1200.0, 1500.0 }, // 
    { 410.0, 700.0, 800.0, 490.0, 1500.0 }, // 
    { 600.0, 750.0, 770.0, 1000.0, 1500.0 }, // 
    { 910.0, 1001.0, 1200.0, 1300.0, 1500.0 } };
    double[][] mapData2 = new double[][] { // 
    { 800.0, 1000.0, 1200.0, 1300.0, 1450.0 }, // 
    { 500.0, 700.0, 800.0, 900.0, 1100.0 }, // 
    { 450.0, 430.0, 600.0, 800.0, 450.0 }, // 
    { 600.0, 750.0, 780.0, 1000.0, 1250.0 } };
    double xres = 60.0;
    double yres = 60.0;
    OmsRasterReader reader = new OmsRasterReader();
    reader.pXres = xres;
    reader.pYres = yres;
    reader.file = arcPath;
    reader.process();
    GridCoverage2D readCoverage = reader.outRaster;
    checkMatrixEqual(readCoverage.getRenderedImage(), mapData1);
    reader = new OmsRasterReader();
    reader.pXres = xres;
    reader.pYres = yres;
    reader.file = grassPath;
    reader.process();
    readCoverage = reader.outRaster;
    checkMatrixEqual(readCoverage.getRenderedImage(), mapData2);
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) OmsRasterReader(org.hortonmachine.gears.io.rasterreader.OmsRasterReader)

Example 4 with OmsRasterReader

use of org.hortonmachine.gears.io.rasterreader.OmsRasterReader in project hortonmachine by TheHortonMachine.

the class TestRasterReader method testRasterReaderBoundsAndRes.

public void testRasterReaderBoundsAndRes() throws Exception {
    double[][] mapData = new double[][] { // 
    { 1000.0, 1200.0, 1250.0, 1300.0, 1450.0 }, // 
    { 700.0, 800.0, 850.0, 900.0, 1100.0 }, // 
    { 650.0, 750.0, 800.0, 850.0, 450.0 }, // 
    { 700.0, 760.0, 770.0, 850.0, 1150.0 } };
    double n = 5140020.0;
    double s = 5139840.0;
    double w = 1640710.0;
    double e = 1640920.0;
    double xres = 45.0;
    double yres = 45.0;
    OmsRasterReader reader = new OmsRasterReader();
    reader.file = arcPath;
    reader.pNorth = n;
    reader.pSouth = s;
    reader.pWest = w;
    reader.pEast = e;
    reader.pXres = xres;
    reader.pYres = yres;
    reader.process();
    GridCoverage2D readCoverage = reader.outRaster;
    checkMatrixEqual(readCoverage.getRenderedImage(), mapData);
    reader = new OmsRasterReader();
    reader.file = grassPath;
    reader.pNorth = n;
    reader.pSouth = s;
    reader.pWest = w;
    reader.pEast = e;
    reader.pXres = xres;
    reader.pYres = yres;
    reader.process();
    readCoverage = reader.outRaster;
    checkMatrixEqual(readCoverage.getRenderedImage(), mapData);
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) OmsRasterReader(org.hortonmachine.gears.io.rasterreader.OmsRasterReader)

Example 5 with OmsRasterReader

use of org.hortonmachine.gears.io.rasterreader.OmsRasterReader in project hortonmachine by TheHortonMachine.

the class TestRasterReader method testRasterReaderAll.

public void testRasterReaderAll() throws Exception {
    OmsRasterReader reader = new OmsRasterReader();
    reader.file = arcPath;
    reader.process();
    GridCoverage2D readCoverage = reader.outRaster;
    double[][] mapData = new double[][] { // 
    { 800, 900, 1000, 1000, 1200, 1250, 1300, 1350, 1450, 1500 }, // 
    { 600, -9999.0, 750, 850, 860, 900, 1000, 1200, 1250, 1500 }, // 
    { 500, 550, 700, 750, 800, 850, 900, 1000, 1100, 1500 }, // 
    { 400, 410, 650, 700, 750, 800, 850, 490, 450, 1500 }, // 
    { 450, 550, 430, 500, 600, 700, 800, 500, 450, 1500 }, // 
    { 500, 600, 700, 750, 760, 770, 850, 1000, 1150, 1500 }, // 
    { 600, 700, 750, 800, 780, 790, 1000, 1100, 1250, 1500 }, { 800, 910, 980, 1001, 1150, 1200, 1250, 1300, 1450, 1500 } };
    checkMatrixEqual(readCoverage.getRenderedImage(), mapData);
    reader = new OmsRasterReader();
    reader.file = grassPath;
    reader.process();
    readCoverage = reader.outRaster;
    // grass rasters have Double.NaN novalues
    mapData = new double[][] { // 
    { 800, 900, 1000, 1000, 1200, 1250, 1300, 1350, 1450, 1500 }, // 
    { 600, Double.NaN, 750, 850, 860, 900, 1000, 1200, 1250, 1500 }, // 
    { 500, 550, 700, 750, 800, 850, 900, 1000, 1100, 1500 }, // 
    { 400, 410, 650, 700, 750, 800, 850, 490, 450, 1500 }, // 
    { 450, 550, 430, 500, 600, 700, 800, 500, 450, 1500 }, // 
    { 500, 600, 700, 750, 760, 770, 850, 1000, 1150, 1500 }, // 
    { 600, 700, 750, 800, 780, 790, 1000, 1100, 1250, 1500 }, { 800, 910, 980, 1001, 1150, 1200, 1250, 1300, 1450, 1500 } };
    checkMatrixEqual(readCoverage.getRenderedImage(), mapData);
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) OmsRasterReader(org.hortonmachine.gears.io.rasterreader.OmsRasterReader)

Aggregations

OmsRasterReader (org.hortonmachine.gears.io.rasterreader.OmsRasterReader)12 GridCoverage2D (org.geotools.coverage.grid.GridCoverage2D)10 Execute (oms3.annotations.Execute)4 File (java.io.File)2 GridGeometry2D (org.geotools.coverage.grid.GridGeometry2D)2 SimpleFeatureCollection (org.geotools.data.simple.SimpleFeatureCollection)2 RegionMap (org.hortonmachine.gears.utils.RegionMap)2 WritableRaster (java.awt.image.WritableRaster)1 IOException (java.io.IOException)1 URL (java.net.URL)1 AbstractGridCoverage2DReader (org.geotools.coverage.grid.io.AbstractGridCoverage2DReader)1 AbstractGridFormat (org.geotools.coverage.grid.io.AbstractGridFormat)1 FileDataStore (org.geotools.data.FileDataStore)1 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)1 DefaultFeatureCollection (org.geotools.feature.DefaultFeatureCollection)1 GrassCoverageReader (org.geotools.gce.grassraster.GrassCoverageReader)1 Envelope2D (org.geotools.geometry.Envelope2D)1 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)1 ReferencedEnvelope3D (org.geotools.geometry.jts.ReferencedEnvelope3D)1 FeatureLayer (org.geotools.map.FeatureLayer)1