This CD-ROM contains global Top-of-the Atmopshere (TOA) images and products derived from Advanced Very High Resolution Radiometer (AVHRR). These products were developed on a Silicon Graphics Inc. (SGI) workstation using the C language as part of the Global Vegetation Index (GVI) project by the Climate Research and Applications Division (CRAD) Land Surface Team of the Office of Research and Applications (ORA). The data on this CD-ROM consists of D-Level products, which are described in the GVI Users Guide (Kidwell, 1994). In order to ensure easy portability across all platforms, the data was scaled to 8-bits or 1-byte. Each uncompressed image is made up of 2500 columns and 904 rows of data, with 0.144 degrees (nominally 0.15 degrees) latitude/longitude resolution, giving a total size of 2260000 bytes/image. The purpose of this section is to read the 2500 x 904 image.
Each image is read by rows, starting with row 1 at 75 N, and ending with row 904 at 55 S. Every row begins at 180 W longtiude, and each sucessive map cell would be 0.144 degrees east of the previous map cell. Therefore, the upper left corner of the image starts at 75 N, 180 W, and ends in the lower right corner of the image, at 55 S, 180 E. The physical range of the data is between 0 and 255, with all ocean values containing the value 0.
Since the binary imagery is character data, you cannot browse through it. Howver, the character data can be easily converted into integer values. The following is a list of FORTRAN and C programs that can be used as a guide for reading the files. Each of these programs will convert the character data into integer values. Reading the 8-bit imagery is somewhat platform specific. The coding is broken down by language and platform. NOTE: THE OUTPUT DATA IS BEING WRITTEN TO UNIT=6, THE SCREEN.
The following program can be universally used on all platforms which have a C compiler.
#include <stdio.h> #include <math.h> #include <stdlib.h> /* The purpose of this program is to read 1-byte plate carree images (C-level or D-level) and output them as ascii text one byte at a time. One word of caution, if you are using a VAX DEC ALPHA machine, then you need to make sure that the data has been stored in 2500 byte blocks, NOT 512 byte blocks. */ static FILE *fp1, *fp2; void main(int argc, char *argv[]) { char image[2260000]; int xsize=2500, ysize=904; register int i; short data; if (argc != 3) { printf("usage -- image_read inputfile outputfile\n"); exit(EXIT_FAILURE); } if (!(fp1=fopen(argv[1],"rb"))) { printf("Cannot open file %s to read\n",argv[1]); exit(EXIT_FAILURE); } if (!(fp2=fopen(argv[2],"w"))) { printf("Cannot open file %s to write\n",argv[2]); exit(EXIT_FAILURE); } fread(&image[0],1,xsize*ysize,fp1); for(i=0;i<2260000;i++) { data=(short) image[i]; fprintf(fp2,"%d\n",data); } /* Write output to user-defined file */ } To compile the program, use the following command: cc read_image.c -o read_image Then to run the program, use the following: read_image inputfile outputfile where, read_image = The executable inputfile = The input 8-bit binary image outputfile = The output ASCII image
The output ASCII image will be a sequential file, with each pixel constituting a new record. Therefore, the entire image will have 2260000 records/lines.
file://c.html
Revised: 25 February 1997