Search in sources :

Example 1 with RasterBandData

use of org.locationtech.geowave.format.sentinel2.RasterBandData in project geowave by locationtech.

the class AmazonImageryProvider method getCoverage.

/**
 * Fetch the coverage of the specified band in the specified workspace directory
 */
@Override
public RasterBandData getCoverage(final SimpleFeature band, final String workspaceDir) throws IOException {
    final File sceneDir = DownloadRunner.getSceneDirectory(band, workspaceDir);
    final String entityId = (String) band.getAttribute(SceneFeatureIterator.ENTITY_ID_ATTRIBUTE_NAME);
    final String productId = (String) band.getAttribute(SceneFeatureIterator.PRODUCT_ID_ATTRIBUTE_NAME);
    final String bandName = (String) band.getAttribute(BandFeatureIterator.BAND_ATTRIBUTE_NAME);
    final File file = new File(sceneDir + File.separator + AWS_SCENE_RESOURCE_NAMES.get(bandName));
    if (!file.exists()) {
        final String downloadUrl = (String) band.getAttribute(SceneFeatureIterator.SCENE_DOWNLOAD_ATTRIBUTE_NAME);
        downloadFile(downloadUrl, sceneDir, bandName);
    }
    if (file.exists()) {
        final JP2ECWReader reader = new JP2ECWReader(file);
        final GridCoverage2D coverage = reader.read(null);
        reader.dispose();
        return new RasterBandData(entityId + "_" + bandName, coverage, reader, NO_DATA_VALUE);
    }
    throw new IOException("The file of the '" + productId + "_" + bandName + "' coverage does not exist");
}
Also used : JP2ECWReader(org.geotools.coverageio.gdal.jp2ecw.JP2ECWReader) GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) IOException(java.io.IOException) File(java.io.File) RasterBandData(org.locationtech.geowave.format.sentinel2.RasterBandData)

Example 2 with RasterBandData

use of org.locationtech.geowave.format.sentinel2.RasterBandData in project geowave by locationtech.

the class TheiaImageryProvider method getCoverage.

/**
 * Fetch the coverage of the specified band in the specified workspace directory
 */
@Override
public RasterBandData getCoverage(final SimpleFeature band, final String workspaceDir) throws IOException {
    final File sceneDir = DownloadRunner.getSceneDirectory(band, workspaceDir);
    final String entityId = (String) band.getAttribute(SceneFeatureIterator.ENTITY_ID_ATTRIBUTE_NAME);
    final String productId = (String) band.getAttribute(SceneFeatureIterator.PRODUCT_ID_ATTRIBUTE_NAME);
    final String bandName = (String) band.getAttribute(BandFeatureIterator.BAND_ATTRIBUTE_NAME);
    final File file = sceneDir;
    final String[] fileList = sceneDir.list();
    if (fileList != null) {
        for (final String name : fileList) {
            final File temp = new File(file.getAbsolutePath() + File.separatorChar + name);
            if (temp.isDirectory() && name.toUpperCase(Locale.ENGLISH).startsWith(productId.toUpperCase(Locale.ENGLISH))) {
                // We provide the coverage in ground reflectance with the
                // correction of slope effects.
                // The full description of the product format is here:
                // 'https://theia.cnes.fr/atdistrib/documents/PSC-NT-411-0362-CNES_01_00_SENTINEL-2A_L2A_Products_Description.pdf'
                // A more succinct one is also available here:
                // 'http://www.cesbio.ups-tlse.fr/multitemp/?page_id=8352'
                // 
                final File geotiffFile = new File(file.getAbsolutePath() + File.separatorChar + name + File.separatorChar + name + "_FRE_" + bandName + ".tif");
                if (geotiffFile.exists()) {
                    final GDALGeoTiffReader reader = new GDALGeoTiffReader(geotiffFile);
                    final GridCoverage2D coverage = reader.read(null);
                    reader.dispose();
                    return new RasterBandData(entityId + "_" + bandName, coverage, reader, NO_DATA_VALUE);
                }
            }
        }
    }
    throw new IOException("The file of the '" + productId + "_" + bandName + "' coverage does not exist");
}
Also used : GridCoverage2D(org.geotools.coverage.grid.GridCoverage2D) GDALGeoTiffReader(org.locationtech.geowave.adapter.raster.plugin.gdal.GDALGeoTiffReader) IOException(java.io.IOException) File(java.io.File) RasterBandData(org.locationtech.geowave.format.sentinel2.RasterBandData)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 GridCoverage2D (org.geotools.coverage.grid.GridCoverage2D)2 RasterBandData (org.locationtech.geowave.format.sentinel2.RasterBandData)2 JP2ECWReader (org.geotools.coverageio.gdal.jp2ecw.JP2ECWReader)1 GDALGeoTiffReader (org.locationtech.geowave.adapter.raster.plugin.gdal.GDALGeoTiffReader)1