TiffDataWriter extends DataWriter { @Override public void write() { List<VortexGrid> grids = data.stream() .filter(vortexData -> vortexData instanceof VortexGrid) .map(vortexData -> (VortexGrid) vortexData) .collect(Collectors.toList()); grids.forEach(grid -> { Dataset dataset = RasterUtils.getDatasetFromVortexGrid(grid); ArrayList<String> gdalOptions = new ArrayList<>(); gdalOptions.add("-of"); gdalOptions.add("Gtiff"); gdalOptions.add("-ot"); gdalOptions.add("Float32"); gdalOptions.add("-co"); gdalOptions.add("TILED=YES"); gdalOptions.add("-co"); gdalOptions.add("COMPRESS=DEFLATE"); gdalOptions.add("-co"); gdalOptions.add("ZLEVEL=1"); gdalOptions.add("-co"); gdalOptions.add("BIGTIFF=YES"); TranslateOptions translateOptions = new TranslateOptions(new Vector<>(gdalOptions)); Dataset out = gdal.Translate(destination.toString(), dataset, translateOptions); out.FlushCache(); out.delete(); }); } TiffDataWriter(DataWriterBuilder builder); @Override void write();  }
@Test void TiffDataWriterWritesGribFile(){ String inFile = new File(getClass().getResource( "/MRMS_GaugeCorr_QPE_01H_00.00_20170102-120000.grib2").getFile()).toString(); String variableName = "GaugeCorrQPE01H_altitude_above_msl"; DataReader reader = DataReader.builder() .path(inFile) .variable(variableName) .build(); List<VortexData> dtos = new ArrayList<>(reader.getDtos()); Path destination = Paths.get("C:/Temp/.tiff"); DataWriter writer = DataWriter.builder() .destination(destination) .data(dtos) .build(); writer.write(); }
@Test void TiffDataWriterWritesDssFile(){ String inFile = new File(getClass().getResource( "/normalizer/qpe.dss").getFile()).toString(); String variableName = " DataReader reader = DataReader.builder() .path(inFile) .variable(variableName) .build(); List<VortexData> dtos = new ArrayList<>(reader.getDtos()); Path destination = Paths.get("C:/Temp/.tiff"); DataWriter writer = DataWriter.builder() .destination(destination) .data(dtos) .build(); writer.write(); }