From: Anaxa G. <ana...@gm...> - 2008-05-29 15:47:36
|
Ok so I get an idea of why it did not work : I replaced : MapContext context = new DefaultMapContext(DefaultGeographicCRS.WGS84); context.setTitle(projDir.getName()); with : MapContext context = new DefaultMapContext(DefaultGeographicCRS.WGS84); context.setTitle(projDir.getName()); try { context.setCoordinateReferenceSystem(CRS.decode("epsg:4326")); } catch (TransformException ex) { Exceptions.printStackTrace(ex); } catch (FactoryException ex) { Exceptions.printStackTrace(ex); } Now I dont get anymore my projections problem, but this error : java.lang.IllegalArgumentException: Le numéro de bande 1 n'est pas valide. at org.geotools.coverage.TypeMap.getColorInterpretation(TypeMap.java:513) at org.geotools.renderer.lite.gridcoverage2d.ColorMapNode.execute(ColorMapNode.java:296) at org.geotools.renderer.lite.gridcoverage2d.ColorMapNode.execute(ColorMapNode.java:52) at org.geotools.renderer.lite.gridcoverage2d.StyleVisitorCoverageProcessingNodeAdapter$1.execute(StyleVisitorCoverageProcessingNodeAdapter.java:139) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.checkExecuted(BaseCoverageProcessingNode.java:234) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:336) Caused: org.geotools.coverage.processing.CoverageProcessingException at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:338) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:41) at org.geotools.renderer.lite.gridcoverage2d.StyleVisitorCoverageProcessingNodeAdapter.getOutput(StyleVisitorCoverageProcessingNodeAdapter.java:179) at org.geotools.renderer.lite.gridcoverage2d.ContrastEnhancementNode.execute(ContrastEnhancementNode.java:233) at org.geotools.renderer.lite.gridcoverage2d.ContrastEnhancementNode.execute(ContrastEnhancementNode.java:75) at org.geotools.renderer.lite.gridcoverage2d.StyleVisitorCoverageProcessingNodeAdapter$1.execute(StyleVisitorCoverageProcessingNodeAdapter.java:139) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.checkExecuted(BaseCoverageProcessingNode.java:234) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:336) Caused: org.geotools.coverage.processing.CoverageProcessingException at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:338) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:41) at org.geotools.renderer.lite.gridcoverage2d.StyleVisitorCoverageProcessingNodeAdapter.getOutput(StyleVisitorCoverageProcessingNodeAdapter.java:179) at org.geotools.renderer.lite.gridcoverage2d.SubchainStyleVisitorCoverageProcessingAdapter.execute(SubchainStyleVisitorCoverageProcessingAdapter.java:111) at org.geotools.renderer.lite.gridcoverage2d.RasterSymbolizerHelper.execute(RasterSymbolizerHelper.java:67) at org.geotools.renderer.lite.gridcoverage2d.RasterSymbolizerHelper.execute(RasterSymbolizerHelper.java:47) at org.geotools.renderer.lite.gridcoverage2d.StyleVisitorCoverageProcessingNodeAdapter$1.execute(StyleVisitorCoverageProcessingNodeAdapter.java:139) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.checkExecuted(BaseCoverageProcessingNode.java:234) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:336) Caused: org.geotools.coverage.processing.CoverageProcessingException at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:338) at org.geotools.renderer.lite.gridcoverage2d.BaseCoverageProcessingNode.getOutput(BaseCoverageProcessingNode.java:41) at org.geotools.renderer.lite.gridcoverage2d.StyleVisitorCoverageProcessingNodeAdapter.getOutput(StyleVisitorCoverageProcessingNodeAdapter.java:179) at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:555) at org.geotools.renderer.lite.StreamingRenderer.renderRaster(StreamingRenderer.java:1848) at org.geotools.renderer.lite.StreamingRenderer.processSymbolizers(StreamingRenderer.java:1708) at org.geotools.renderer.lite.StreamingRenderer.process(StreamingRenderer.java:1654) at org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1598) at org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:642) at org.geotools.renderer.shape.ShapefileRenderer.renderWithStreamingRenderer(ShapefileRenderer.java:1475) at org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1344) at org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:266) at org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1500) at org.geotools.gui.swing.map.map2d.stream.strategy.SingleBufferedImageStrategy.createBufferImage(SingleBufferedImageStrategy.java:132) [catch] at org.geotools.gui.swing.map.map2d.stream.strategy.SingleBufferedImageStrategy$DrawingThread.run(SingleBufferedImageStrategy.java:252) My raster is a one band raster.. but I cant understand the problem... I use a lot of single band raster (like SRTM) and I get no problem ! I suppose that it can be my way to stylize the raster. Currently, I have a single band raster with two values : 0 (I want this value to be transparent) and 200. I have a colormap in my geotiff. So I would like to get it and then create my style from this colormap... is this possible ? Thanks, Thomas 2008/5/29 Anaxa Gore <ana...@gm...>: > Hi, > > I tried to open the coverage separatly with a little GT test program and it > works well... I cant understand why it doesnt work in my software... > > Thomas > > 2008/5/29 Anaxa Gore <ana...@gm...>: > > Simone, >> >> I updated GT and tried again... but get always the same errors ... Even >> though, I get now the same error for the reader and the gridcoverage >> directly : >> >> java.lang.AssertionError: GeneralEnvelope[(-6.17974497540872, >> 35.46771885962336), (-5.321163738368728, 36.16702771345159)] >> at >> org.geotools.geometry.GeneralEnvelope.intersect(GeneralEnvelope.java:951) >> at >> org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:471) >> at >> org.geotools.renderer.lite.StreamingRenderer.renderRaster(StreamingRenderer.java:1848) >> at >> org.geotools.renderer.lite.StreamingRenderer.processSymbolizers(StreamingRenderer.java:1708) >> at >> org.geotools.renderer.lite.StreamingRenderer.process(StreamingRenderer.java:1654) >> at >> org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1598) >> at >> org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:642) >> at >> org.geotools.renderer.shape.ShapefileRenderer.renderWithStreamingRenderer(ShapefileRenderer.java:1475) >> at >> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1344) >> at >> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:266) >> at >> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1500) >> at >> org.geotools.gui.swing.map.map2d.stream.strategy.SingleBufferedImageStrategy.createBufferImage(SingleBufferedImageStrategy.java:132) >> [catch] at >> org.geotools.gui.swing.map.map2d.stream.strategy.SingleBufferedImageStrategy$DrawingThread.run(SingleBufferedImageStrategy.java:252) >> >> Do you get another idea ? >> >> Thomas >> >> 2008/5/29 Simone Giannecchini <sim...@gm...>: >> >>> Thomas, >>> I would try to update at least the coverage modules for geotools then >>> I would test things again. >>> >>> >>> Simone. >>> >>> On Thu, May 29, 2008 at 2:46 PM, Anaxa Gore <ana...@gm...> >>> wrote: >>> > Hi, >>> > >>> > Aymen : I can't understand what you mean... Of course it is a >>> projection >>> > problem, but I use the Johann's widgets for a while and it does'nt >>> change >>> > anything... Thanks anyway for your idea !! >>> > Simone : I am always using GT 2.5 trunk, but havent made any update >>> since a >>> > long time... (2 or 3 weeks). I dont know what to provide you more than >>> what >>> > i already gave : the building of my geotiff and the reading... I dont >>> know >>> > where to specify eventually the CRS to put into the Geotiff... Do you >>> have >>> > some code working for writing geotiff and then displaying it ? >>> > >>> > Thomas >>> > >>> > >>> > 2008/5/29 Simone Giannecchini <sim...@gm...>: >>> >> >>> >> Ciao Anaxa, >>> >> which version of geotools are you working with? Did you update >>> recently? >>> >> >>> >> Anywa, can you please try to isolate your code and provide a test case >>> >> that I can ply with? >>> >> >>> >> >>> >> Simone. >>> >> >>> >> On Wed, May 28, 2008 at 5:17 PM, Anaxa Gore <ana...@gm... >>> > >>> >> wrote: >>> >> > Hi, >>> >> > >>> >> > I am writing some geotiff and would like then open them using GT ! >>> >> > My writing operation is thi s: >>> >> > >>> >> > GridCoverageFactory gcf = new GridCoverageFactory(); >>> >> > Color[][] colors = new Color[][] {{Color.WHITE, color}}; >>> >> > GridCoverage2D gc = gcf.create("Horizon Coverage", rasterCoverage, >>> >> > this.rasterEnvelope,null,null,null,colors,null); >>> >> > >>> >> > // The Format used to write a geotiff file. >>> >> > final GeoTiffFormat format = new GeoTiffFormat(); >>> >> > // The parameters used to write a geotiff file. >>> >> > final GeoTiffWriteParams wp = new GeoTiffWriteParams(); >>> >> > >>> >> > // No compression -> never mind the size of pictures, we must go >>> fast >>> >> > wp.setCompressionMode(GeoTiffWriteParams.MODE_DISABLED); >>> >> > // We keep the tile size >>> >> > wp.setTilingMode(GeoToolsWriteParams.MODE_DEFAULT); >>> >> > >>> >> > final ParameterValueGroup paramWrite = format.getWriteParameters(); >>> >> > >>> >> > >>> paramWrite.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp); >>> >> > >>> >> > File outFile = new >>> >> > >>> File(getCoveragesFolder(true).getPath()+File.separator+"coverage.TIF"); >>> >> > GeoTiffWriter gtw = (GeoTiffWriter)format.getWriter(outFile); >>> >> > >>> gtw.write(gc,(GeneralParameterValue[])paramWrite.values().toArray(new >>> >> > GeneralParameterValue[1])); >>> >> > >>> >> > >>> >> > When I have done this, I want to read this geotiff newly created, >>> like >>> >> > this >>> >> > : >>> >> > >>> >> > Hints hints = new Hints(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER, >>> >> > Boolean.TRUE); >>> >> > GeoTiffReader reader = new GeoTiffReader(outFile, hints); >>> >> > MapLayer coveragelayer = new DefaultMapLayer(reader.read(null), >>> >> > getCoverageLayerStyle()); >>> >> > coveragelayer.setTitle("_"); >>> >> > >>> >> > context.addLayer(coveragelayer); >>> >> > >>> >> > But then , I got this message : >>> >> > >>> >> > org.opengis.referencing.operation.OperationNotFoundException: Les >>> >> > paramètres >>> >> > de Bursa Wolf sont requis. >>> >> > at >>> >> > >>> >> > >>> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1070) >>> >> > at >>> >> > >>> >> > >>> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1134) >>> >> > at >>> >> > >>> >> > >>> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:879) >>> >> > at >>> >> > >>> >> > >>> org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:237) >>> >> > at >>> >> > >>> >> > >>> org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:253) >>> >> > at org.geotools.referencing.CRS.findMathTransform(CRS.java:947) >>> >> > at org.geotools.referencing.CRS.findMathTransform(CRS.java:915) >>> >> > at >>> >> > >>> >> > >>> org.geotools.coverage.grid.io.AbstractGridCoverage2DReader.getResolution(AbstractGridCoverage2DReader.java:673) >>> >> > Caused: org.geotools.data.DataSourceException: Unable to get >>> resolution >>> >> > at >>> >> > >>> >> > >>> org.geotools.coverage.grid.io.AbstractGridCoverage2DReader.getResolution(AbstractGridCoverage2DReader.java:688) >>> >> > at >>> >> > >>> >> > >>> org.geotools.coverage.grid.io.AbstractGridCoverage2DReader.setReadParams(AbstractGridCoverage2DReader.java:255) >>> >> > at >>> >> > org.geotools.gce.geotiff.GeoTiffReader.read(GeoTiffReader.java:389) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.renderRaster(StreamingRenderer.java:1845) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.processSymbolizers(StreamingRenderer.java:1710) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.process(StreamingRenderer.java:1656) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1600) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:644) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.renderWithStreamingRenderer(ShapefileRenderer.java:1456) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1325) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:266) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1481) >>> >> > at >>> >> > >>> >> > >>> org.geotools.gui.swing.map.map2d.strategy.SingleBufferedImageStrategy.createBufferImage(SingleBufferedImageStrategy.java:132) >>> >> > [catch] at >>> >> > >>> >> > >>> org.geotools.gui.swing.map.map2d.strategy.SingleBufferedImageStrategy$DrawingThread.run(SingleBufferedImageStrategy.java:252) >>> >> > >>> >> > So I tried to put in the layer the GridCoverage directly instead of >>> the >>> >> > GeotiffReader, >>> >> > and then, i got this message : >>> >> > >>> >> > java.lang.AssertionError: GeneralEnvelope[(-40.72106049886832, >>> >> > -20.690664198797137), (-39.931656537188424, -19.945989698912875)] >>> >> > at >>> >> > >>> >> > >>> org.geotools.geometry.GeneralEnvelope.intersect(GeneralEnvelope.java:918) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.paint(GridCoverageRenderer.java:471) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.renderRaster(StreamingRenderer.java:1782) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.processSymbolizers(StreamingRenderer.java:1710) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.process(StreamingRenderer.java:1656) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:1600) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:644) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.renderWithStreamingRenderer(ShapefileRenderer.java:1456) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1325) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:266) >>> >> > at >>> >> > >>> >> > >>> org.geotools.renderer.shape.ShapefileRenderer.paint(ShapefileRenderer.java:1481) >>> >> > at >>> >> > >>> >> > >>> org.geotools.gui.swing.map.map2d.strategy.SingleBufferedImageStrategy.createBufferImage(SingleBufferedImageStrategy.java:132) >>> >> > [catch] at >>> >> > >>> >> > >>> org.geotools.gui.swing.map.map2d.strategy.SingleBufferedImageStrategy$DrawingThread.run(SingleBufferedImageStrategy.java:252) >>> >> > >>> >> > I cant fix the problem... >>> >> > I can open the created geotiff in QGis with no problem, and can find >>> >> > this in >>> >> > the Properties/Metadatas : >>> >> > >>> >> > Driver: >>> >> > >>> >> > GTiff >>> >> > GeoTIFF >>> >> > >>> >> > Description du jeu de données >>> >> > >>> >> > C:\Documents and Settings\Thomas\Mes >>> >> > documents\NetBeansProjects\Vitoria\Coverages\coverage.TIF >>> >> > >>> >> > AREA_OR_POINT=Point >>> >> > >>> >> > Dimensions: >>> >> > >>> >> > X:947 Y:893Bandes:1 >>> >> > >>> >> > Aucune valeur de données >>> >> > >>> >> > *NoDataValue not set* >>> >> > >>> >> > Type de Donnée: >>> >> > >>> >> > GDT_Byte - nombre entier non signé de huit bits >>> >> > >>> >> > Vues d'ensemble de pyramide: >>> >> > >>> >> > Système Spatial De Référence De la Couche: >>> >> > >>> >> > +proj=longlat +ellps=WGS84 +no_defs >>> >> > >>> >> > Origine: >>> >> > >>> >> > -40.7206,-19.9464 >>> >> > >>> >> > Taille du Pixel: >>> >> > >>> >> > 0.000833584,-0.000833902 >>> >> > >>> >> > Propriétés >>> >> > >>> >> > Valeur >>> >> > >>> >> > Bande >>> >> > >>> >> > 1 : Palette >>> >> > >>> >> > Bande No >>> >> > >>> >> > 1 >>> >> > >>> >> > Pas de stats >>> >> > >>> >> > Pas de stats encore collectées >>> >> > >>> >> > If anybody gets an idea... >>> >> > Thanks in advance >>> >> > Thomas >>> >> > >>> >> > >>> >> > >>> >> > >>> ------------------------------------------------------------------------- >>> >> > This SF.net email is sponsored by: Microsoft >>> >> > Defy all challenges. Microsoft(R) Visual Studio 2008. >>> >> > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> >> > _______________________________________________ >>> >> > Geotools-gt2-users mailing list >>> >> > Geo...@li... >>> >> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >>> >> > >>> >> > >>> >> >>> >> >>> >> >>> >> -- >>> >> ------------------------------------------------------- >>> >> Eng. Simone Giannecchini >>> >> President /CEO GeoSolutions S.A.S. >>> >> Via Carignoni 51 >>> >> 55041 Camaiore (LU) >>> >> Italy >>> >> >>> >> phone: +39 0584983027 >>> >> fax: +39 0584983027 >>> >> mob: +39 333 8128928 >>> >> >>> >> >>> >> http://www.geo-solutions.it >>> >> >>> >> ------------------------------------------------------- >>> > >>> > >>> >>> >>> >>> -- >>> ------------------------------------------------------- >>> Eng. Simone Giannecchini >>> President /CEO GeoSolutions S.A.S. >>> Via Carignoni 51 >>> 55041 Camaiore (LU) >>> Italy >>> >>> phone: +39 0584983027 >>> fax: +39 0584983027 >>> mob: +39 333 8128928 >>> >>> >>> http://www.geo-solutions.it >>> >>> ------------------------------------------------------- >>> >> >> > |