I have a GeoTiff-File and want to display it. So I used the example (http://docs.codehaus.org/display/GEOTOOLS/A+HowTo+for+beginners) for that purpose. But there is no Tiff shown when I start that small Testing-Application (Code below).
I'm not sure but I think it may have something to do with the Coordinate System. So I used the ListgeoG.exe-Tool to find something out about my GeoTiff (see result below). But I don't know what to do with that, because it seems that the StyledMapPane ignores the CS passed to it like done in this snippet (http://docs.codehaus.org/display/GEOTOOLS/Adding+Tools+to+a+Map). I tried to load this and other GeoTiffs into uDig but that failed as well. What is wrong with my application, what do I have to add/change? If GeoTools can't work with every kind of GeoTiff, can anybody give me an example GeoTiff that GeoTools can handle? Thank you, Andre ########################################### ### GeoTiff Metadata ### ########################################### Geotiff_Information: Version: 1 Key_Revision: 1.0 Tagged_Information: ModelTiepointTag (2,3): 0 0 0 573475 6026969 0 ModelPixelScaleTag (1,3): 0.25 0.25 0 End_Of_Tags. Keyed_Information: GTModelTypeGeoKey (Short,1): ModelTypeProjected GTRasterTypeGeoKey (Short,1): RasterPixelIsArea GeogGeodeticDatumGeoKey (Short,1): Datum_WGS84 GeogEllipsoidGeoKey (Short,1): Ellipse_WGS_84 ProjNatOriginLongGeoKey (Double,1): 9 ProjNatOriginLatGeoKey (Double,1): 0 ProjFalseEastingGeoKey (Double,1): 5e+011 ProjFalseNorthingGeoKey (Double,1): 0 ProjScaleAtNatOriginGeoKey (Double,1): 0.9996 PCSCitationGeoKey (Ascii,61): "Universal Transverse Mercator; WGS84; WGS84; Zone Number 32N" ProjectedCSTypeGeoKey (Short,1): PCS_WGS84_UTM_zone_32N ProjLinearUnitsGeoKey (Short,1): Linear_Meter End_Of_Keys. End_Of_Geotiff. PCS = 32632 (name unknown) Projection = 16032 () Projection Method: CT_TransverseMercator ProjNatOriginLatGeoKey: 0.000000 ( 0d 0' 0.00"N) ProjNatOriginLongGeoKey: 9.000000 ( 9d 0' 0.00"E) ProjScaleAtNatOriginGeoKey: 0.999600 ProjFalseEastingGeoKey: 500000.000000 m ProjFalseNorthingGeoKey: 0.000000 m GCS: 4326/WGS 84 Datum: 6326/World Geodetic System 1984 Ellipsoid: 7030/WGS 84 (6378137.00,6356752.31) Prime Meridian: 8901/Greenwich (0.000000/ 0d 0' 0.00"E) Projection Linear Units: 9001/metre (1.000000m) Corner Coordinates: Upper Left ( 573475.000, 6026969.000) Lower Left ( 573475.000, 6025789.000) Upper Right ( 574383.000, 6026969.000) Lower Right ( 574383.000, 6025789.000) Center ( 573929.000, 6026379.000) ########################################## ### Test App ### ########################################## import java.awt.Color; import java.awt.Component; import java.io.File; import java.io.IOException; import javax.swing.JFrame; import org.geotools.gce.geotiff.GeoTiffFormat; import org.geotools.gce.geotiff.GeoTiffReader; import org.geotools.gui.swing.StyledMapPane; import org.geotools.map.DefaultMapContext; import org.geotools.map.MapContext; import org.geotools.styling.ColorMap; import org.geotools.styling.RasterSymbolizer; import org.geotools.styling.Style; import org.geotools.styling.StyleBuilder; import org.opengis.coverage.grid.GridCoverage; public class GeoTiff { /** * */ public GeoTiff() { super(); } /** * What this Method does * * @param args */ public static void main(String[] args) { MapContext map = new DefaultMapContext(); File tiffFile = new File("C:/path to file/file.tif");//Windows //Load the image GeoTiffReader rdr = (GeoTiffReader) ((new GeoTiffFormat()).getReader(tiffFile)); GridCoverage tiffCov = null; try { tiffCov = rdr.read(null); } catch (IOException e) { e.printStackTrace(); } //We do not use any parametery here. //Determine the data's display style. We style it as a digital elevation model //using interpolated color ramps for the different heights. The example below //assumes a 16 bit image, since the standard 8 bit tiff images only have values //between 0 and 255. StyleBuilder sb = new StyleBuilder(); ColorMap cm = sb.createColorMap( new double[] { 1000, 1200, 1400, 1600, 2000 }, new Color[] { new Color(0, 255, 0), new Color(255, 255, 0), new Color(255, 127, 0), new Color(191, 127, 63), new Color(255, 255, 255)}, ColorMap.TYPE_RAMP); RasterSymbolizer rsDem = sb.createRasterSymbolizer(cm, 1); Style demStyle = sb.createStyle(rsDem); //Put the data into a map: map.addLayer(tiffCov, demStyle ); StyledMapPane m_MapPane = null; try { // Create MapPane m_MapPane = new StyledMapPane(); m_MapPane.setMapContext(map); } catch (Exception e) { // I'm sure they won't be thrown since I'm working with a // FeatureCollection } JFrame Fenster = new JFrame(); Fenster.setContentPane(m_MapPane); Fenster.setSize(800,600); Fenster.show(); } } ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
