To: support-netcdf-java@xxxxxxxxxxxxxxxx
From: "andrew fox" <andrew.m.fox@xxxxxxxxxxxxxx>
Subject: netCDF Java - How do I export a single variable to a GeoTiff
file?
Organization: USDA
Keywords: 200408272156.i7RLuqsB013099
Institution: U.S.D.A APHIS
Package Version: UI Webstart version
Operating System: Win XP Pro
Hardware Information: Dell workstation: dual intel xeon 2.37 GHz
processor, 2 GB RAM
Inquiry: I am trying to use the Java netstart netcdf UI tool
interface:
http://my.unidata.ucar.edu/content/software/netcdf-java/v2.1/webstart/index.html?unidata=5ecf7c4c34abe333603544ecc312610d
I have a netcdf file with about 50 variables in a matrix form
registered to a map grid. I am trying to use the netcdf UI program to
export a single variable to a GeoTiff file. I created a folder in:
C:\data\geotiff\test to hold output geotiff files and am able to
create a single geotiff file from the .nc file but I cannot figure out
how to export a single variable from the netcdf file to a geotiff
file? Is it possible to export a single variable from a netcdf file
containing many variables to a geotiff file?
Thanks very much!
Andrew Fox
Andrew,
The answer is yes and this is how geotiff api designed. Here is
a example you can refernece (assuming that you already have netcdf-java
packages):
import ucar.ma2.*;
import ucar.nc2.*;
import ucar.nc2.dataset.*;
import ucar.nc2.geotiff;
import ucar.nc2.dataset.grid.*;
import ucar.unidata.geoloc.*;
import ucar.unidata.geoloc.projection.*;
import java.io.*;
import java.util.*;
public static void main(String args[]) throws IOException {
String fileOut = "totalr1.tif";
GeotiffWriter writer = new GeotiffWriter(fileOut);
writer.writeGrid("dods://www.cdc.noaa.gov/cgi-bin/nph-nc/Datasets/noaa.oisst.v2/sst.mnmean.nc",
"sst", 0, 0,false);
//writer.writeGrid("/home/yuanho/dev/netcdf-java/geotiff/2003072918_avn-x.nc",
"T", 0, 0, true, llr);
writer.close();
}
Let me know if you need further help.
Yuan
support@xxxxxxxxxxxxxxxx
****************************************************************************
Unidata User Support UCAR Unidata
(303)497-8643 P.O.
support@xxxxxxxxxxxxxxxx Boulder, CO
----------------------------------------------------------------------------
Unidata WWW Service
----------------------------------------------------------------------------
NOTE: All email exchanges with Unidata User Support are recorded in the
Unidata inquiry tracking system and then made publically available
through the web. If you do not want to have your interactions made
available in this way, you must let us know in each email you send to us.