[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20030707: 20030701:GEMPAK NIDS display



Daryl,

The only projections allowed by the GINI data format are STR, LCC, 
(and what they call) MER.

First off as I'm out the door is that KXKY should be 1701;1201
since you have to count the starting row/column, right?

As it stands, your dx and dy is not 1km, and I doubt that the resolution
provided by a 3 byte integer (GINI format again) will represent that number
accurately. What I suspect is happening is that your mapserver is calculating
the pole point of the projection, and that is a big number (row/col) multiplied
by your error in dx and dy, which magnifies the error.

Steve Chiswell



>From: Daryl Herzmann <address@hidden>
>Organization: UCAR/Unidata
>Keywords: 200307072256.h67MuxLd024330

>Hiya UNIDATA (Steve),
>
>I am producing images from the procedure outlined below without any 
>problem, but after interrogating the image some more, I notice that the 
>geo-referencing is off by 25-50 km or so (at least according to mapserver)
>
>I am curious how I can debug this situation.  I am assuming that mapserver 
>can display geo-referenced rasters correctly...
>
>Here is a resulting image.  The thunderstorm line in central Iowa is ~1 
>county too far south....
>
>http://mesonet.agron.iastate.edu/pickup/unidata/output.png
>
>For nex2gini, I use
> GRDAREA  = 37.00;-104.00;49.00;-87.00
> PROJ     = MER
> KXKY     = 1700;1200
>
>and my geo-reference world file is
>        0.010000000000000
>        0.00000
>        0.00000
>       -0.010000000000000
>     -104.000000
>       49.0000
>
>
>Wild guess here.  Doesn't the mercator projection do some stretching at 
>higher latitudes?  That would seem to explain the displacement south in 
>the middle of the image?   Wouldn't I want to use a CED projection?  But 
>alas, nex2gini does not support CED....
>
>Sorry for the trouble,
>  Daryl
>
>On Tue, 1 Jul 2003, Unidata Support wrote:
>
>>>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 forwar
> d.
>>
>>Steve Chiswell
>>**************************************************************************** 
>>Unidata User Support                                    UCAR Unidata Program 
>>(303)497-8644                                                  P.O. Box 3000 
>>address@hidden                                   Boulder, CO 80307 
>>---------------------------------------------------------------------------- 
>>Unidata WWW Service                        http://www.unidata.ucar.edu/      
>>**************************************************************************** 
>>
>
>-- 
>/**
> * Daryl Herzmann (address@hidden)
> * Program Assistant -- Iowa Environmental Mesonet
> * http://mesonet.agron.iastate.edu
> */
>