[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[udig-devel] Udig problem reading sample values of geotiff
|
I'm reading the
sample values of geotiff with this simple code:
public
static void main(String[]
args)
{
try
{
System.
out
.println(java.nio.charset.Charset.defaultCharset().name());
//
System.exit(0);
//
Set the default locale to pre-defined locale
//
Locale.setDefault(new Locale("en", "US"));
BufferedImage image = ImageIO.read(
new File(
"C:\\aaa\\combustibile.tif"));
Raster rr = image.getRaster();
int[] bandOffsets = new int[rr.getNumBands()];
int dd =
rr.getSampleModel().getDataType();
for (int z = 0; z
< rr.getSampleModel().getNumBands(); z++)
for (int i = 0; i
< rr.getWidth(); i++)
for (int j = 0; j
< rr.getHeight(); j++)
{
String sample = getSample(i, j, z, dd, rr);
System.
out.println("Sample value " +
sample);
}
} catch
(IOException ex)
{
ex.printStackTrace();
}
}
private
static String getSample(int i, int j, int z, int type,
final Raster raster)
{
String result =
"";
try
{
switch (type)
{
case TIFFTag.TIFF_BYTE:
result =
"" + raster.getSample(i, j, z);
break;
case TIFFTag.TIFF_UINT32:
result =
"" + raster.getSample(i, j, z);
break;
case TIFFTag.TIFF_FOLAT32:
result =
"" + raster.getSampleFloat(i, j,
z);
break;
case TIFFTag.TIFF_INT16:
result =
"" + raster.getSample(i, j, z);
break;
case TIFFTag.TIFF_UINT16:
result =
"" + raster.getSample(i, j, z);
break;
default:
break;
}
}
catch (IllegalArgumentException a)
{
a.printStackTrace();
throw a;
}
catch (ClassCastException e)
{
e.printStackTrace();
throw e;
}
return result;
}
and I obtain the
correct values for example 4.0
When I change the
raster image read on filesystem, with the rendered image obtained by udig
raster layer, I obtain different values. For example in the pixel with
value 4.0 I found 1.512366E38.
Where is the
problem?
How can I solve
it?
Cheers
Pasquale
Paola
....................................................................................................
Pasquale
Paola
Engineering Ingegneria Informatica S.p.a.
Direzione: Ricerca ed Innovazione
Via
Terragneta, 90
80058 Torre Annunziata (NA)
Tel.
+39.081.862.68.21
Fax +39.081.862.68.19
e-mail:pasquale.paola@xxxxxx
http://www.linkedin.com/in/pasqualepaola
BEGIN:VCARD
VERSION:2.1
N:Paola;Pasquale;;Dott.
FN:Pasquale Paola
ORG:Engineering Ingegneria Informatica s.p.a.
TEL;WORK;VOICE:0818626821
TEL;WORK;FAX:0818626819
ADR;WORK:;;Via Terragneta, 90;Torre Annunziata;NAPOLI;80058;Italia
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Via Terragneta, 90=0D=0ATorre Annunziata, NAPOLI 80058=0D=0AItalia
BDAY:20060625
EMAIL;PREF;INTERNET:pasquale.paola@xxxxxx
EMAIL;INTERNET:pasquale.paola@xxxxxxxxx
REV:20080512T140913Z
END:VCARD