[netcdf-java] Creating geoTiff - retaining data values

Hello all,

I'm attempting to create geoTiff images from a large number of netCDF files.

A portion of my test code is below:

LatLonPointImpl p1 = new LatLonPointImpl(38.0625, -80.6875); // lower left LatLonPointImpl p2 = new LatLonPointImpl(47.8125, -67.0625); // upper right
LatLonRect llr = new LatLonRect(p1, p2);
GeotiffWriter writer = new GeotiffWriter ("NE_1961-1990_Yearly_Max_Temp.tif"); writer.writeGrid("NE_1961-1990_Yearly_Max-Temp.nc", "tmax", 0, 0, true, llr);

(netCDF file here: http://temagami.tosm.ttu.edu/~jvandorn/netcdf/ NE_1961-1990_Yearly_Max_Temp.nc)

This does produce a viewable image from the netCDF file:
(viewable here: http://temagami.tosm.ttu.edu/~jvandorn/netcdf/ netcdfLibToTiffGrayScaleTrue.tif)

However the pixel values in the tif image when viewed in something that works with geoTiffs (e.g., Mirone) do not reflect their original values. Meaning, the original input netCDF file is showing maximum temperatures (http://temagami.tosm.ttu.edu/~jvandorn/netcdf/ NE_1961-1990_Yearly_Max_Temp.png), which roughly range from 7 to 25 oC (with a missing value of -999), but the resulting tiff scale seems to range from 1 to 255.

Per the API, there's a boolean greyScale setting in the GeotiffWriter.writeGrid method. Is this the expected result when that is set to true? That it outputs a grey scale image, where the pixel values are now in terms of 1 to 255, instead of their original values?

I've tried setting grayScale to false, in hopes that it would actually retain the original data values but nothing really seems to make much sense of that result: (http://temagami.tosm.ttu.edu/~jvandorn/netcdf/ netcdfLibToTiffGrayScaleFalse.tif).

So, my basic question is, can I produce a geoTiff image that will contain the same range of pixel (i.e., data) values that the original netCDF file shows?

Thank you for any help/suggestions on this.
Jeff
  • 2008 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: