1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#include "hdf.h"
/*
* In this example we will (1) open the "GridFile" HDF file, (2) attach to
* the "UTMGrid", and (3) read data from the "Vegetation" field.
*/
main()
{
intn i, j, status;
int32 gdfid, GDid;
float32 f32=1.0;
float32 veg[200][120];
/*
* Open the HDF grid file, "GridFile.hdf".
*/
gdfid = GDopen("GridFile_created_with_hadeos_sample_file_writer_of_HDFEOS2_version_219_or_higher_release.hdf", DFACC_RDWR);
if (gdfid != -1)
{
/*
* Attach the "UTMGrid".
*/
GDid = GDattach(gdfid, "UTMGrid");
if (GDid != -1)
{
status = GDreadfield(GDid, "Vegetation",
NULL, NULL, NULL, veg);
if (status == -1)
{
printf("\t\tError: Cannot read field \"Vegetation\"\n");
return -1;
}
status = GDreadattr(GDid, "float32", &f32);
if (status == -1)
{
printf("\t\tError: Cannot read attribute \"float32\"\n");
return -1;
}
}
}
GDdetach(GDid);
GDclose(gdfid);
return 0;
}
|