From: Andrea A. <and...@gm...> - 2007-01-30 10:50:25
|
Hi Daniele, at a first look it seems that you do not have the jai packages in the path. Apart of that I paste a snip of code that Simone gave me to make things work properly with geotiffs in both cases with worldfile or not: File tiffFile = new File(imagePath); AbstractGridCoverage2DReader rdr = null; if (geotiff) rdr = new GeoTiffReader(tiffFile); else rdr = new WorldImageReader(tiffFile); crs = rdr.getCrs(); dataEnvelope = new ReferencedEnvelope(rdr.getOriginalEnvelope(), crs); // between 0 and 255. StyleBuilder sb = new StyleBuilder(); RasterSymbolizer rsDem = sb.createRasterSymbolizer(); org.geotools.styling.Style demStyle = sb.createStyle(rsDem); // map map = new DefaultMapContext(crs); map.addLayer(rdr, demStyle); map.setCoordinateReferenceSystem(crs); map.setAreaOfInterest(dataEnvelope); mp.setMapArea(dataEnvelope); As Simone states in a previous post, not the coverage, but the reader should be passed to the context. Regards, Andrea Daniele Bellandi wrote: > Hi to all, > I'm trying to render a GeoTiff file inside my JMapPane. > I've encountered this exception: > > Exception in thread "AWT-EventQueue-0" > java.lang.NoClassDefFoundError: > com/sun/media/imageioimpl/plugins/tiff/TIFFImageReaderSpi > > It is thrown when I try to create a GeoTiffFormat. > This seems to be a problem connected with Jai, I've tried to install > jai-1.1.2 or jai-1.1.3 but I've always the same problem. > > This is the part of my code: > > File tiffFile = new File("pathGeoTiffFile"); > context = new DefaultMapContext(DefaultGeographicCRS.WGS84); > GeoTiffFormat f_rdr = new GeoTiffFormat(); > GeoTiffReader rdr = (GeoTiffReader) f_rdr.getReader(tiffFile); > GridCoverage2D tiffCov = (GridCoverage2D)rdr.read(null); > StyleBuilder sb = new StyleBuilder(); > RasterSymbolizer rsDem = sb.createRasterSymbolizer(); > org.geotools.styling.Style demStyle = sb.createStyle(rsDem); > context.addLayer(tiffCov, demStyle ); > > Is this the right way for loading geotiff? Or is better to use another way? > > Thanks in advance, > > Daniele > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Geotools-gt2-users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > -- ____________________________________________________________________________ HydroloGIS - Environmental Safety Modelling www.hydrologis.com Andrea Antonello Environmental Engineer mobile: +393288497722 "Let it be as much a great honour to take as to give learning, if you want to be called wise." Skuggsja' - The King's mirror - 1240 Reykjavik ____________________________________________________________________________ |