Package org.geotools.coverage

Examples of org.geotools.coverage.GridSampleDimension


        return null;
    }

    static double getCandidateNoData(GridCoverage gc) {
        // no data management
        final GridSampleDimension sd = (GridSampleDimension) gc
                .getSampleDimension(0);
        final List<Category> categories = sd.getCategories();
        double inNoData = Double.NaN;
        if (categories != null) {
            final Iterator<Category> it = categories.iterator();
            Category candidate;
            final String noDataName = Vocabulary.format(VocabularyKeys.NODATA);
View Full Code Here


         */
        final GridSampleDimension[] result = new GridSampleDimension[numBands];
        final Category[]        categoryXS = new Category[bandLists.length];
        final Unit<?>[]             unitXS = new Unit[bandLists.length];
        while (--numBands >= 0) {
            GridSampleDimension sampleDim = null;
            Category[]      categoryArray = null;
            int       indexOfQuantitative = 0;
            assert PRIMARY_SOURCE_INDEX == 0; // See comment below.
            for (int i=bandLists.length; --i>=0;) {
                if (bandLists[i] == null) {
          continue;
        }
                /*
                 * Iterates among all sources (i) for the current band. We iterate
                 * sources in reverse order because the primary source MUST be the
                 * last one iterated, in order to have proper values for variables
                 * 'sampleDim', 'categoryArray' and 'indexOfQuantitative' after the
                 * loop.
                 */
                final GridSampleDimension[] allBands = bandLists[i];
                sampleDim = allBands[allBands.length == 1 ? 0 : numBands];
                final List<Category> categories = sampleDim.getCategories();
                // GridSampleDimension may contain no categories
                if (categories == null || categories.isEmpty()) {
                    result[numBands] = sampleDim;
                    continue;
                }
                categoryArray       = (Category[]) categories.toArray();
                indexOfQuantitative = getQuantitative(categoryArray);
                if (indexOfQuantitative < 0) {
                    return null;
                }
                unitXS    [i] = sampleDim.getUnits();
                categoryXS[i] = categoryArray[indexOfQuantitative];
            }
            if (categoryArray == null) {
                continue;
            }
            final Category oldCategory = categoryArray[indexOfQuantitative];
            final Unit<?>  oldUnit     = sampleDim.getUnits();
            final Category newCategory = deriveCategory(categoryXS, parameters);
            final Unit<?>  newUnit     = deriveUnit(unitXS, parameters);
            if (newCategory == null) {
                return null;
            }
            if (!oldCategory.equals(newCategory) || !Utilities.equals(oldUnit, newUnit)) {
                /*
                 * Create a new sample dimension. Note that we use a null title, not the same
                 * title than the original sample dimension, because the new sample dimension
                 * may be quite different. For example the original sample dimension may be
                 * about "Temperature" in °C units, and the new one about "Gradiant magnitude
                 * of Temperature" in °C/km units. The GridSampleDimension constructor will
                 * infers the title from what looks like the "main" category.
                 */
                final CharSequence title = null;
                categoryArray[indexOfQuantitative] = newCategory;
                result[numBands] = new GridSampleDimension(title, categoryArray, newUnit);
            } else {
                // Reuse the category list from the primary source.
                result[numBands] = sampleDim;
            }
        }
View Full Code Here

        if (image == null) {
            final int numBands = variables.size();
            if (numBands == 0) {
                image = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_GRAY);
            } else {
                final GridSampleDimension sd = variables.get(0).getSampleDimension();
                final ColorModel cm;
                if (numBands == 1) {
                    cm = sd.getColorModel();
                } else {
                    cm = sd.getColorModel(0, numBands);
                }
                final WritableRaster raster = cm.createCompatibleWritableRaster(width, height);
                image = new BufferedImage(cm, raster, false, null);
            }
        }
View Full Code Here

                    categories[i++] = new Category(entry.getValue(), null, sample);
                }
                range = NumberRange.create(lower, true, upper, false);
                categories[i] = new Category(name, null, range, (transform != null) ?
                                             transform : LinearTransform1D.IDENTITY);
                sampleDimension = new GridSampleDimension(name, categories, units);
            }
            return sampleDimension;
        }
View Full Code Here

        final GridCoverage2D coverage2D = CoverageFactoryFinder.getGridCoverageFactory(null)
                .create("coverage",
                        image,
                        new GridGeometry2D(new GridEnvelope2D(PlanarImage.wrapRenderedImage(image)
                                .getBounds()), transform, DefaultGeographicCRS.WGS84),
                        new GridSampleDimension[] { new GridSampleDimension("coverage") }, null,
                        null);

        final File fileshp = TestData.file(this, "testpolygon.shp");
        final DataStore store = FileDataStoreFinder.getDataStore(fileshp.toURI().toURL());
        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = store
View Full Code Here

        final GridCoverage2D coverage2D = CoverageFactoryFinder.getGridCoverageFactory(null)
                .create("coverage",
                        image,
                        new GridGeometry2D(new GridEnvelope2D(PlanarImage.wrapRenderedImage(image)
                                .getBounds()), transform, DefaultGeographicCRS.WGS84),
                        new GridSampleDimension[] { new GridSampleDimension("coverage") }, null,
                        null);

        final File fileshp = TestData.file(this, "testpolygon.shp");
        final DataStore store = FileDataStoreFinder.getDataStore(fileshp.toURI().toURL());
        FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = store
View Full Code Here

    // setting bands names.
    for (int i = 0; i < numBands; i++) {
            final ColorInterpretation colorInterpretation=TypeMap.getColorInterpretation(cm, i);
            if(colorInterpretation==null)
                   assertFalse("Unrecognized sample dimension type",true);
      bands[i] = new GridSampleDimension(colorInterpretation.name()).geophysics(true);
    }       
        final GridCoverage2D newCoverage=
          CoverageFactoryFinder.getGridCoverageFactory(null).create(
              "sample",
              rgbImage,
View Full Code Here

        for (int i=0; i<bands.length; i++) {
            /*
             * Extracts the ARGB codes from the IndexColorModel and invokes the
             * transformColormap(...) method, which needs to be defined by subclasses.
             */
            GridSampleDimension band = bands[i];
            final ColorModel candidate = (i == visibleBand) ? image.getColorModel() : band.getColorModel();
            if (!(candidate instanceof IndexColorModel)) {
                // Current implementation supports only sources that use an index color model.
                throw new IllegalArgumentException(Errors.format(ErrorKeys.ILLEGAL_CLASS_$2,
                        Classes.getClass(candidate), IndexColorModel.class));
            }
View Full Code Here

            coverage2D = CoverageFactoryFinder.getGridCoverageFactory(null).create(
                    "coverage",
                    image,
                    new GridGeometry2D(new GridEnvelope2D(PlanarImage.wrapRenderedImage(image)
                            .getBounds()), transform, DefaultGeographicCRS.WGS84),
                    new GridSampleDimension[] { new GridSampleDimension("coverage") }, null, null);
            assertNotNull(coverage2D);

            // build the classificator
            // generate the classificator image
            final BufferedImage imageClassificator = new BufferedImage(120, 80,
                    BufferedImage.TYPE_BYTE_INDEXED);
            final WritableRaster raster = imageClassificator.getRaster();
            for (int i = raster.getWidth(); --i >= 0;) {
                for (int j = raster.getHeight(); --j >= 0;) {
                    // create a simple raster used for classification
                    int sampleValue = (i % 2 == 0) ? 1 : 2;
                    raster.setSample(i, j, 0, sampleValue);
                }
            }
            // create the coverage for the classification layer
            covClassificator = CoverageFactoryFinder.getGridCoverageFactory(null).create(
                    "coverageClassificator",
                    imageClassificator,
                    new GridGeometry2D(new GridEnvelope2D(PlanarImage.wrapRenderedImage(
                            imageClassificator).getBounds()), coverage2D.getEnvelope()),
                    new GridSampleDimension[] { new GridSampleDimension("coverage") }, null, null);
            assertNotNull(coverage2D);

            // invoke the process
            SimpleFeatureCollection sfc = process.execute(coverage2D, null, featureCollection,
                    covClassificator);
View Full Code Here

            return null;
        }
        // Get the names of the bands
        String[] sampleDimensionNames = new String[numBands];
        for( int i = 0; i < numBands; i++ ) {
            GridSampleDimension dim = cov.getSampleDimension(i);
            sampleDimensionNames[i] = dim.getDescription().toString();
        }
        final int RED = 0, GREEN = 1, BLUE = 2;
        int[] channelNum = {-1, -1, -1};
        // We examine the band names looking for "red...", "green...", "blue...".
        // Note that the channel numbers we record are indexed from 1, not 0.
View Full Code Here

TOP

Related Classes of org.geotools.coverage.GridSampleDimension

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.