This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>From: Unidata User Support <address@hidden> >Organization: Unidata Program Center/UCAR >Keywords: Daryl, Following up on our converastion last week regarding obtaining a lat/lon mapping of a NIDS product: GRDAREA = 35.8;-101.4;48.0;-87.1 PROJ = mer KXKY = 200;200 CPYFIL = GFUNC = n0r RADTIM = 030701/1700 RADDUR = 30 RADFRQ = STNFIL = nexrad.tbl RADMODE = pc SATFIL = test.gray COMPRESS = no GEMPAK-NEX2GINI> The above produces a GINI file called test.gray. The GINI header will be 533 bytes, so the remaining 40000 bytes (200x200) are the pixel values of a lat/lon raster with corners as specified. This was what I believe you were looking for. There are several ways to deal with the raster. The easiest is to just treat the values a gray scale (byte) values which can be display using tools such as imagemagick: display -size 200x200+533 -depth 8 test.gray Another method would be to convert the raw indicies to RGB values using the GEMPAK color table (eg osf_ref16.tbl), such as : /* Note, names hardcoded here as an example */ #include <stdio.h> #include <string.h> int main() { int i, ncol; FILE *fp; char line[256]; int ir, ig, ib, ix; unsigned char carr[40000]; unsigned char red[256]; unsigned char green[256]; unsigned char blue[256]; /* open color table */ if((fp = fopen("/home/gempak/NAWIPS/gempak/tables/luts/osf_ref16.tbl","r")) == NULL) { printf("color table file not found\n"); exit(-1); } /* read color table values */ ncol = 0; while(fgets(line,255,fp) != NULL) { if(line[0] == '!') continue; sscanf(line+23,"%d %d %d",&ir, &ig, &ib); red[ncol] = ir; green[ncol] = ig; blue[ncol] = ib; ncol++; } fclose(fp); /* open image file, seek to start of raster, load image */ fp = fopen("test.gray", "r"); fseek(fp,533, SEEK_SET); fread (carr, 1, 40000, fp); fclose(fp); /* output RGB values */ fp = fopen("test.rgb", "w"); for(i=0;i<40000;i++) { ix = ( (float)(ncol-1) / 255.0 ) * (float)carr[i]; fwrite(&red[ix], 1, 1, fp); fwrite(&green[ix], 1, 1, fp); fwrite(&blue[ix], 1, 1, fp); } fclose(fp); } Now the image can be displayed (or converted to the preferred format) with display -geometry 900x900 -size 200x200 -depth 8 test.rgb or convert -size 200x200 -depth 8 test.rgb test.gif So, this is all readily done using simple tools. But, I would believe that the real solution would be to create a "nex2gini" that would write the GEOtiff directly (since it knows the projection and values). If this is what you need, I can create that tool as a one step process. As a dataset for a server, if you were to use nex2gini to create a single composite mosaic for the entire country, then selecting the appropriate region from the larger image for the display product would be straight forward. Steve Chiswell