From: Joseph O. <jo...@lo...> - 2015-07-06 14:02:58
|
Hi - I'm very interested in using GeoTools HeatmapProcess to handle raster data from Apache Solr Cloud. So far I've been able to generate views from the raster data using a GridCoverage2D, but when I try to apply the heat map process, I get an empty frame. Any tips? Thank you! -Joe ------------------------------------------------ /** * Create a new coverage from the given data array. All non-zero array * values are written to the coverage as 1; zero values as 0. */ public GridCoverage2D makeBinaryCoverage(int[][] data) { GridCoverageFactory gcf = CoverageFactoryFinder.getGridCoverageFactory(null); // Assume data array is in row-major order final int dataW = data[0].length; final int dataH = data.length; final int imgTileW = 128; // image tile sample model SampleModel sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE, imgTileW, imgTileW, 1, imgTileW, new int[]{0}); ColorModel cm = TiledImage.createColorModel(sm); TiledImage img = new TiledImage(0, 0, dataW, dataH, 0, 0, sm, cm); System.out.println("DataH: "+dataH+" dataW: "+dataW); for (int y = 0; y < dataH; y++) { for (int x = 0; x < dataW; x++) { if (data[y][x] != 0) { img.setSample(x, y, 0, data[y][x]); } } } // Set world coords as 1:1 with image coords for this example ReferencedEnvelope env = new ReferencedEnvelope( new Rectangle2D.Double(0, 0, dataW, dataH), DefaultEngineeringCRS.CARTESIAN_2D); return gcf.create("HeatMap", img, env); } ------------------------------------------------ |