CRS.transform(gridToWorldCorner, new GeneralEnvelope(testRange.getBounds())); testEnvelope.setCoordinateReferenceSystem(reader.getCoordinateReferenceSystem()); sampleDimensions = gc.getSampleDimensions(); gc.dispose(true); if (gc.getRenderedImage() instanceof PlanarImage) { ImageUtilities.disposePlanarImageChain((PlanarImage) gc.getRenderedImage()); + format.getName()); final int numBands = sm.getNumBands(); sampleDimensions = new GridSampleDimension[numBands]; throw new IOException( "Unrecognized sample dimension type for band number " + (i + 1)); sampleDimensions[i] = new GridSampleDimension(colorInterpretation.name());
public static WrappedSampleDimension build( GridSampleDimension sampleDim, CoverageDimensionInfo info) { String name = info.getName(); final InternationalString sampleDimDescription = sampleDim.getDescription(); InternationalString configuredDescription = (sampleDimDescription == null ? new SimpleInternationalString(name) : sampleDimDescription; final List<Category> categories = sampleDim.getCategories(); NumberRange configuredRange = info.getRange(); final String uom = info.getUnit(); Unit defaultUnit = sampleDim.getUnits(); Unit unit = defaultUnit; try { configuredNoDataValues = sampleDim.getNoDataValues(); for (Category category : categories) { wrapped = category; if (Category.NODATA.getName().equals(category.getName())) { if (category.isQuantitative()) { Category.NODATA.getName(), category.getColors(), NumberRange.create(minimum, maximum));
@Override public NumberRange<? extends Number> getRange() { return super.getRange(); }
CoverageDimensionInfo dim = catalog.getFactory().createCoverageDimension(); GridSampleDimension sd = sampleDimensions[i]; String name = sd.getDescription().toString(Locale.getDefault()); dim.setName(name); final Unit uom = sd.getUnits(); dim.setDimensionType(sd.getSampleDimensionType()); double sdMin = sd.getMinimumValue(); double sdMax = sd.getMaximumValue(); label.append("[".intern()); label.append(sdMin); dim.setRange(NumberRange.create(sdMin, sdMax)); final List<Category> categories = sd.getCategories(); if (categories != null) { for (Category cat : categories) { && cat.getName().toString(Locale.ENGLISH).equalsIgnoreCase("no data")) { double min = cat.getRange().getMinimum(); double max = cat.getRange().getMaximum();
coverageDim.setName(wrappedName); coverageDim.setDimensionType(SampleDimensionType.SIGNED_16BITS); coverageDim.setRange(NumberRange.create(0d, 10000d)); new GridSampleDimension( "original", new Category[] { new Category( Vocabulary.formatInternational(VocabularyKeys.NODATA), new Color[] {new Color(0, 0, 0, 0)}, NumberRange.create(-9999, -9999)) }, null); List<Category> categories = copy.getCategories(); assertTrue(category.getName().equals(Category.NODATA.getName())); assertEquals(category.getRange().getMinimum(), noData1, DELTA); assertEquals(category.getRange().getMaximum(), noData1, DELTA);
protected GridCoverage2D execute() { return CoverageFactoryFinder.getGridCoverageFactory(null) .create( "name", PlanarImage.wrapRenderedImage( RasterSymbolizerTest.getSynthetic(Double.NaN)), new GeneralEnvelope( new double[] {-90, -180}, new double[] {90, 180}), new GridSampleDimension[] { new GridSampleDimension( "sd", new Category[] { new Category("", Color.BLACK, 0) }, null) }, null, null); } };
RenderedImage sourceImage = forceToRGB(source.getRenderedImage(), true); int numBands = composedImage.getSampleModel().getNumBands(); GridSampleDimension[] sd = new GridSampleDimension[numBands]; for (int i = 0; i < numBands; i++) { sd[i] = new GridSampleDimension( TypeMap.getColorInterpretation(composedImage.getColorModel(), i) .name()); return factory.create( source.getName().toString(), gridCoverageImage, (GridGeometry2D) source.getGridGeometry(), sd, new GridCoverage[] {source},
private GridCoverage2D prepareCoverage(RenderedImage image) throws IOException { // creating bands final SampleModel sm = image.getSampleModel(); final ColorModel cm = image.getColorModel(); final int numBands = sm.getNumBands(); final GridSampleDimension[] bands = new GridSampleDimension[numBands]; // setting bands names. for (int i = 0; i < numBands; i++) { final ColorInterpretation colorInterpretation = TypeMap.getColorInterpretation(cm, i); if (colorInterpretation == null) throw new IOException("Unrecognized sample dimension type"); bands[i] = new GridSampleDimension(colorInterpretation.name()); } return coverageFactory.create( rasterManager.getCoverageIdentifier(), image, new GeneralEnvelope(bbox), bands, null, null); }
RenderedImage outputImage = output.getRenderedImage(); int numBands = outputImageSampleModel.getNumBands(); final int dataType = outputImageSampleModel.getDataType(); GridSampleDimension sd[]; if (numBands > 4) { finalImage = ow.applyOpacity(opacity).getRenderedImage(); numBands = finalImage.getSampleModel().getNumBands(); sd = new GridSampleDimension[numBands]; for (int i = 0; i < numBands; i++) { sd[i] = new GridSampleDimension( TypeMap.getColorInterpretation(finalImage.getColorModel(), i) .name()); .create( output.getName(), finalImage, .create( output.getName(), outputImage,
final int numBands = sm.getNumBands(); final GridSampleDimension[] bands = new GridSampleDimension[numBands]; if (!Double.isNaN(noData)) { noDataCategory = new Category( Vocabulary.formatInternational(VocabularyKeys.NODATA), new Color[] {new Color(0, 0, 0, 0)}, NumberRange.create(noData, noData)); CoverageUtilities.setNoDataProperty(properties, new Double(noData)); image.setProperty(NoDataContainer.GC_NODATA, new NoDataContainer(noData)); bandName = "Band" + (i + 1); bands[i] = new GridSampleDimension(bandName, categories, null); return coverageFactory.create( coverageName, image, crs, raster2Model, bands, null, properties); return coverageFactory.create( coverageName, image, new GeneralEnvelope(originalEnvelope), bands, null,
(GridCoverage2D) currentSourceNode.getOutput(); sourceGridCoverages.add(currentSourceCoverage); final GridGeometry2D gg = (GridGeometry2D) currentSourceCoverage.getGridGeometry(); if (gridGeometry == null) { op = currentSourceCoverage.getRenderedImage(); w.setImage(op); w.setROI(CoverageUtilities.getROIProperty(currentSourceCoverage)); intermediateOps.add(op); op = w.format(op.getSampleModel().getDataType()).getRenderedImage(); final GridSampleDimension[] sd = new GridSampleDimension[op.getSampleModel().getNumBands()]; for (int i = 0; i < sd.length; i++) sd[i] = new GridSampleDimension( TypeMap.getColorInterpretation(op.getColorModel(), i).name()); CoverageUtilities.setROIProperty(properties, w.getROI()); return getCoverageFactory() .create( "BandMerge", op,
String coverageName = sampleGranule.getName().toString(); int dataType = sampleGranule.getRenderedImage().getSampleModel().getDataType(); GridSampleDimension[] sampleDimensions = sampleGranule.getSampleDimensions(); if (sampleDimensions != null && sampleDimensions.length > 0) { GridSampleDimension sampleDimension = sampleDimensions[0]; inputUoM = sampleDimension.getUnits(); double[] noData = sampleDimension.getNoDataValues(); if (noData != null && noData.length > 0) { noDataValue = noData[0];
final GridGeometry geometry = gc.getGridGeometry(); final int dimensions = geometry.getGridRange().getDimension(); String lower = ""; final GridSampleDimension[] sd = gc.getSampleDimensions(); for (int i = 0; i < sd.length; i++) { writer.write("<CoverageDimension>\n"); writer.write("<name>" + sd[i].getDescription().toString() + "</name>\n"); writer.write("<interval>\n"); writer.write("<min>" + sd[i].getMinimumValue() + "</min>\n"); writer.write("<max>" + sd[i].getMaximumValue() + "</max>\n"); writer.write("</interval>\n"); final List<Category> categories = sd[i].getCategories(); if (categories != null && categories.size() >= 1) { writer.write("<nullValues>\n"); for (Iterator<Category> it = sd[i].getCategories().iterator(); it.hasNext(); ) { Category cat = (Category) it.next(); if ((cat != null) && cat.getName().toString().equalsIgnoreCase("no data")) { double min = cat.getRange().getMinimum(); double max = cat.getRange().getMaximum(); writer.write("<value>" + min + "</value>\n"); if (min != max) writer.write("<value>" + max + "</value>\n");
RenderedImage sourceImage = coverage.getRenderedImage(); final int numbands = sourceImage.getSampleModel().getNumBands(); if (band < 0 || numbands <= band) { throw new ProcessException( new GridSampleDimension("classification", new Category[] {Category.NODATA}, null); final GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints()); HashMap<String, Object> properties = new HashMap<String, Object>() { org.geotools.coverage.util.CoverageUtilities.setROIProperty(properties, worker.getROI()); final GridCoverage2D output = factory.create( "reclassified", indexedClassification, coverage.getGridGeometry(), new GridSampleDimension[] {outSampleDimension}, new GridCoverage[] {coverage},
new AffineTransform( (AffineTransform) ((GridGeometry2D) dataCoverage.getGridGeometry()) .getGridToCRS2D(PixelOrientation.UPPER_LEFT)); final MathTransform w2gTransform; new ReferencedEnvelope(dataCoverage.getEnvelope2D()); ReferencedEnvelope geometryEnvelope = new ReferencedEnvelope( geometry.getEnvelopeInternal(), dataCoverage.getCoordinateReferenceSystem()); if (!coverageEnvelope.intersects((Envelope) geometryEnvelope)) { GridSampleDimension sampleDimension = dataCoverage.getSampleDimension(0); List<Category> categories = sampleDimension.getCategories(); List<Range<Double>> novalueRangeList = null; if (categories != null) { for (Category category : categories) { String catName = category.getName().toString(); if (catName.equalsIgnoreCase("no data")) { NumberRange range = category.getRange(); double min = range.getMinimum(); double max = category.getRange().getMaximum(); if (!Double.isNaN(min) && !Double.isNaN(max)) { param.parameter("Envelope").setValue(new GeneralEnvelope(geometryEnvelope)); cropped = (GridCoverage2D) PROCESSOR.doOperation(param);
final PlanarImage inputImage = (PlanarImage) inputCoverage.getRenderedImage(); ParameterBlockJAI parameterBlock = new ParameterBlockJAI("transpose", "rendered"); parameterBlock.addSource(inputImage); PlanarImage outputImage = JAI.create("transpose", parameterBlock); final int numBands = inputCoverage.getNumSampleDimensions(); return createGridCoverage(inputCoverage.getName(), outputImage); } else { GridSampleDimension[] bands = inputCoverage.getSampleDimensions(); double[] nodataValues = bands[0].getNoDataValues(); Object noData = nodataValues == null ? Integer.MAX_VALUE : nodataValues[0]; properties.put("GC_NODATA", noData); GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null); return factory.create(inputCoverage.getName(), outputImage, Extent, bands, null, properties);
final Object noData = coverage.getProperty(NoDataContainer.GC_NODATA); if (noData != null && noData instanceof NoDataContainer) { return ((NoDataContainer) noData).getAsArray(); final GridSampleDimension[] sampleDimensions = coverage.getSampleDimensions(); final double[] background = new double[sampleDimensions.length]; final int dataType = coverage.getRenderedImage().getSampleModel().getDataType(); for (int i = 0; i < background.length; i++) { final List<Category> categories = sampleDimensions[i].getCategories(); if (categories != null && categories.size() > 0) { for (Category category : categories) { if (category.getName().equals(NODATA)) { background[i] = category.getRange().getMinimum(); found = true; break;
int writeBand) { PlanarImage image = (PlanarImage) gc2D.getRenderedImage(); final int origDataType = image.getSampleModel().getDataType(); .getSampleDimension(0)).geophysics(true); final List oldCategories = visibleSD.getCategories(); if (candidate.getName().toString().equalsIgnoreCase("no data")) { candidateRange = candidate.getRange(); final double oldNoData = candidateRange.getMinimum(); final ParameterBlockJAI pbjM = new ParameterBlockJAI( "org.geotools.gce.gtopo30.NoDataReplacer");
staticInit(); final RenderedImage img = originalGridCoverage.getRenderedImage(); final SampleModel imgSampleModel = img.getSampleModel(); if ((imgSampleModel.getWidth() != tileSize) || (imgSampleModel.getHeight() != tileSize)) { sampleModel = imgSampleModel.createCompatibleSampleModel(tileSize, tileSize); } else { sampleModel = imgSampleModel; this.noDataValuesPerBand = new double[originalGridCoverage.getNumSampleDimensions()][]; for (int d = 0; d < this.noDataValuesPerBand.length; d++) { this.noDataValuesPerBand[d] = originalGridCoverage.getSampleDimension(d).getNoDataValues();
throw new ProcessException("Invalid input, source grid coverage should be not null"); if (band != null && (band < 0 || band >= gc2d.getNumSampleDimensions())) { throw new ProcessException("Invalid input, invalid band number:" + band); (AffineTransform) gc2d.getGridGeometry().getGridToCRS2D(PixelOrientation.CENTER); for (GridSampleDimension sd : gc2d.getSampleDimensions()) { final double[] sdNoData = sd.getNoDataValues(); if (sdNoData != null) { for (double nodata : sdNoData) { if (sd.getCategories() != null) { for (Category cat : sd.getCategories()) { if (cat.getName().equals(NO_DATA)) { final NumberRange<? extends Number> catRange = cat.getRange(); if (!Double.isNaN(catRange.getMinimum())) { if (catRange.getMinimum() == catRange.getMaximum()) { noDataList.add(catRange.getMinimum()); } else {