Using GDAL to Import Data with Subdatasets

TERRSET USERS SEE NOTE BELOW.

 

Typically, the NetCDF and HDF formats contain data with subdatasets. We will illustrate how to import a sample NetCDF dataset that contains subdatasets into the IDRISI .rst format. To import these data you will need to use the latest GDAL IDRISI drivers which can be downloaded from our website at: http://www.clarklabs.org/downloads/gdal. Once downloaded the GDALIDRISI module will need to be configured. See also How to configure GDALIDRISI in IDRISI Help system.

For this illustration we will be using the sample NetCDF dataset: uwnd.mon.mean.nc. This is monthly mean U component of wind, stored in path D:\NetCDF data\uwnd.mon.mean.nc. 

1. Obtaining General Information on the Dataset

Figure_1_GDAL_Info.png

Figure 1: GDALINFO

The first step is to get the general information on the data. Open the GDALIDRISI module through File->Import-> menu. Click the GDALINFO tab, then enter the NetCDF dataset as the input dataset. Then click Run. Information is displayed in the bottom text box. As shown in the figure above, we can use GDALIDRISI and the GDALINFO tab to describe the contents of this dataset, along with the description of the subdataset. 

It is very important at this step step to obtain the full name of the variable that will be imported into IDRISI. Here the variable we are interested in is U wind component, whose name is UWND, representing the monthly mean wind vector U component. We can obtain it from the SUBDATASET_2_NAME item (highlighted part in the figure above), i.e., NETCDF:”D:\NetCDF data\uwnd.mon.mean.nc”:uwnd

 The UWND dataset is composed of four dimensions: 408 X 17 X 73 X 144. According to the metadata from the website of this NetCDF data, the meanings of the four dimensions are listed as follows.

 Temporal – 408 months from 1979-01-01 to 2012-12-31

Pressure level  – 17 pressure levels: 1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10mb

Latitude –  from 1 to 73, that is, 2.5-degree/row for 90S – 90N

Longitude – from 1 to 144, that is, 2.5-degree/column for 0E – 357.5E

This information helps us to decide which datasets to import.

 

2. Obtaining Subdataset detailed information

This next step obtains the metadata of a subdataset to determine which dataset in the subdataset to convert. As mentioned above, in this instance, the variable we are interested in is SUBDATASET_2. This time, we will type a command line in the first text box in GDALIDRISI to query information about SUBDATASET_2, rather than the general information we get from the input dataset input box box. We will need to provide the full name of SUBDATASET_2. Remain in the GDALINFO and type the full name of SUBDATASET_2 so that the first text box reads: "gdalinfo netcdf: "d:\netcdf data\uwnd.mon.mean.nc" :uwnd. Then Run again. See Figure 2.

Read the metadata carefully. Band 1 represents the dataset of the Uwind component in January 1979 when the pressure level is 1000 mb. Band 2 is for the 925 mb level in same month, band 3 is for 850 mb, and so on. Because there are 17 pressure levels, band 18 will start a new cycle of pressure levels with 1000 mb, but for the month of February 1979, instead of January. The rest of the bands apply the same logic. Please note offset and scale, which indicate the dataset is scaled (packed) and needs to be rescaled (unpacked) with the offset and scale parameters.

Figure_2_GDAL_Info_Subdataset.png

Figure 2: GDALINFO and Subdataset Metadata

 

3. Importing a Specific Dataset into IDRISI

If, for example, we intend to import the dataset at the 500 mb pressure level for January 1979, we will need to choose band 6. Click the GDAL_TRANSLATE, in GDALIDRISI. Enter a name for the Output Dataset: uwnd_197901_p500.rst. Then select the Output Format: RST:Idrisi Raster A.1. Enter 6 for the option Selected Bands. Leave all other options blank. Now we need manually input the subdataset by typing in the first input text box the full name of  of SUBDATASET_2 as shown in Figure 3 below, while separating it from output file name with a space. Then click Run to convert.

Figure_3_GDAL_Translate.png

Figure 3: GDALTRANSLATE

 

Once the import is completed, if the data needs to be rescaled, you can use the module CALIBRATE or IMAGE CALCULATOR, to apply, for example, the offset and scale parameters. 

Have more questions? Submit a request

1 Comments

  • 0
    Avatar
    Tammy Woodard, Clark Labs

    GdalIdrisi has been revamped to make it much easier to use, especially if you need to import SubDatasets. Starting with TerrSet patch 18.0.10, released 9/21/15, there is a new interface for Gdalidrisi that makes it easy to select SubDatasets. You won't need to manually type in the subdataset name & you can import all of the bands in a particular subdataset at one time. If you have TerrSet and you need to use Gdalidrisi, update!

Please sign in to leave a comment.
Powered by Zendesk