Hello,
I'm trying to load geotiff files with the following codes but for both I
get an error :
- "java.lang.UnsupportedOperationException: Only Geographic & Projected
Systems are supported. (not code 0)
at
org.geotools.gce.geotiff.GeoTiffCoordinateSystemAdapter.createCoordinateSystem(GeoTiffCoordinateSystemAdapter.java:277)
at org.geotools.gce.geotiff.GeoTiffReader.read(GeoTiffReader.java:216)
at test.GeotiffTest.test2(GeotiffTest.java:77)
at test.GeotiffTest.main(GeotiffTest.java:27)
I've tried to load the files with ArcExplorer (Java Edition) and
everything seems to be ok.
Files are using the Lambert2Etendu coordinate system.
Any idea how to make it works because it's the last thing I've have to do...
Thank's
Jérémy DE ROYER
1)
public static GridCoverage getGridCoverage() {
try {
File tiffFile = new
File("C:/fra5k_108_162_l_l_nt_v21.tif");
debug("tiffFile >" + tiffFile);
// Create the grid coverage reader
// URL url =
GeoTiffReader.class.getClassLoader().getResource("C:/fra5k_108_162_l_l_nt_v21.tif");
// debug("url >" + url);
GeoTiffFormat f = new GeoTiffFormat();
GeoTiffReader reader = (GeoTiffReader) ((new
GeoTiffFormat()).getReader(tiffFile));
//GeoTiffReader reader = (GeoTiffReader)
f.getReader(url);
ParameterGroup paramDescriptor = (ParameterGroup)
f.getReadParameters();
ParameterGroup params = paramDescriptor;
List list = params.values();
GeneralParameterValue genParams[] = new
GeneralParameterValue[list.size()];
for(int i=0; i < list.size(); ++i){
Object obj = list.get(i);
genParams[i] =
(org.geotools.parameter.Parameter) obj;
}
GridCoverage gc = reader.read( genParams );
return gc;
}
catch (Exception e) {
e.printStackTrace();
return null;
}
}
2)
public static void test2() {
try {
MapContext map = new DefaultMapContext();
File tiffFile = new
File("C:/fra5k_108_162_l_l_nt_v21.tif");//Windows
//Load the image
GeoTiffReader rdr = (GeoTiffReader) ((new
GeoTiffFormat()).getReader(tiffFile));
GridCoverage tiffCov = rdr.read(null); //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(); // For the style
convenience
methods below
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 );
}
catch (Exception e) {
e.printStackTrace();
}
}
-------------------------------------------------------
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