From: Jody G. <jga...@re...> - 2007-08-23 22:01:02
|
I am afraid I do not know much about raster support; I know it was slow in GeoTools 2.2 and I tell everyone to upgrade to 2.3 or better :-) So you are on the right track ... You can try contacting the module maintainer for the ArcGrid format (you can check in the pom.xml file in your source download). Are you sure your ArcGrid file has color? I would suspect that green was chosen as the default color and your arcgrid ascii file is single band? I think the mapping of data into colors is the work of a RasterSymbolizer (part of a Style) which you would have to supply. Looking at your example you *did* supply a raster symbolizer. Have you tried stepping through the code to see if your symbolizer is applied? I had a horrible time upgrading the uDig raster rendering code to GeoTools 2.4 (the "new" GridCoverageRenderer does not have good javadocs. I would check the @author tag on that file and start sending email). Simone, Martin, Andrea and Alessio are listed - these are the people best able to help. Jody > Dear Jody Garnett, > > I posted a message about my problem, but nobody answered. So, I am sending you a message about this issues. I believe that you might know about this matter. > > The following is the message I posted: > ---- > I used geotools 2.2.0 for rendering raster (ESRI ArcGrid Ascii file). > Now, I am upgrading to geotools 2.3.3 (or 2.3.4). Then, JMapPane > displays the raster with one color (green). I don't know what I am > doing wrong. The following is the code. Please help me out. > > > > mapPane = new JMapPane(); > > > GTRenderer renderer = new StreamingRenderer(); > > > > mapPane.setRenderer( renderer ); > > > mapPane.setSize( 400, 400 ); > > > // context = new DefaultMapContext( DefaultGeographicCRS.WGS84 ); > > > context = new DefaultMapContext(); > > > > setTitle( "raster test" ); > > > addWindowListener( new WindowAdapter() { > > > public void windowClosing( WindowEvent e ) > { > > > System.exit( 0 ); > > > } > > > } ); > > > > this.setBounds( 20, 20, 450, 450 ); > > > mapPane.setContext( context ); > > > getContentPane().add( mapPane ); > > > setVisible( true ); > > > > File f = new File( "D:\\works\\test.asc" ); > > > ArcGridReader reader = new ArcGridReader( f ); > > > > GridCoverage gcDem = reader.read( null ); > > > StyleBuilder sb = new StyleBuilder(); > > > > ColorMap cm = sb.createColorMap( new String[] { "0.5", > "0.7" }, new double[] { 0.5, 0.7 }, new Color[] { new Color( 255, 0, 0 > ), > > > new Color( 255, 255, 255 ) }, ColorMap.TYPE_RAMP ); > > > RasterSymbolizer rsDem = sb.createRasterSymbolizer( cm, 1 ); > > > Style demStyle = sb.createStyle( rsDem ); > > > > context.addLayer( gcDem, demStyle ); > > > > DirectPosition lowerCorner = gcDem.getEnvelope().getLowerCorner(); > > > DirectPosition upperCorner = gcDem.getEnvelope().getUpperCorner(); > > > Coordinate lowerCoord = new Coordinate( lowerCorner.getCoordinates()[0], lowerCorner.getCoordinates()[1] ); > > > Coordinate upperCoord = new Coordinate( upperCorner.getCoordinates()[0], upperCorner.getCoordinates()[1] ); > > > Envelope envelope = new Envelope( lowerCoord, upperCoord ); > > > > mapPane.setMapArea( envelope ); > > > mapPane.repaint(); > > > ---- > > Thank you for your help in advance. > > > > - Jong > > > > > |