Next Previous Contents

3. Building the composites with GEMPAK

Probably the easiest component of this HOWTO is building the composite image within GEMPAK! If you are running a version of GEMPAK before 5.6.j, you will need to download and install the nex2img program. If you already have nex2img, then you can skip the next subsection.

GEMPAK is publicly available from the UNIDATA website. Installing GEMPAK is way outside the scope of this HOWTO.

Nex2img was written by Steve Chiswell at the UNIDATA Program Center. His program is the key to making this whole system work. Before nex2img, it was extremely tricky to get the geo-referencing of RASTERs, produced in GEMPAK, correct for use within GIS.

3.1 Building nex2img

Building nex2img is very straightforward with GEMPAK already installed.


$ cd $NAWIPS
$ wget https://mesonet.agron.iastate.edu/docs/radmapserver/nex2img.tar.gz
$ tar -zxvf nex2img.tar.gz
$ cd unidata/programs/nex2img
$ make clean
$ make all
$ make install
$ make clean
$ rehash
$ which nex2img

With the nex2img program built, you are now ready to generate the composites.

3.2 Scripting the generation of the composite

This simple script will crank out an image. I am specifying a GRDAREA for Iowa and extended. You will want to modify for your own needs. Keep in mind that this application composites individual site NEXRADs, you can't build a nationwide composite without having all the individual sites.


#!/bin/csh

# Replace to fit your environment!
source /home/nawips/Gemenviron

set gtime=`date -u +'%y%m%d/%H%M'`

rm -f radar.gif radar.tif >& /dev/null

nex2img << EOF > nex2img.log
 GRDAREA  = 37.00;-104.00;48.99;-87.01
 PROJ     = CED
 KXKY     = 1700;1200
 CPYFIL   =  
 GFUNC    = n0r
 RADTIM   = ${gtime}
 RADDUR   = 15
 RADFRQ   = 
 STNFIL   = nexrad.tbl
 RADMODE  = P
 RADFIL   = radar.gif
 LUTFIL   = upc_rad24.tbl
 list
 run

 exit
EOF

if (-e radar.gif) then
  convert radar.gif radar.tif
  cp radar.tif /var/www/htdocs/radmapserver/gisdata
endif

The nex2img program will generate an image called "radar.gif". In order to work with most GIS systems, you will probably want to convert this file to another format namely TIFF, but you can choose JPG or PNG. We then place the radar.tif file in the webserver directory for later use by mapserver.

Without getting too long winded, lets discuss image formats. The easiest format for use within GIS is probably TIFF. Although very large, uncompressed tiff files are extremely fast within GIS. The reason is that the application can "seek" the file to only pull needed data. With compressed formats, an entire set of data needs to be uncompressed and then processed. Also, most people will probably try loading the image in ESRI's ArcView. ArcView likes TIFF files and has built in support for them.

3.3 Geo-referencing the composite image

Now that we have an image, we need to georeference it. Georeferencing of images is done with a world file. A world file is simply a file with 6 lines of meta data describing the navigation of an image. The format is for example:


0.010 (size of pixel in x direction)
0.000000000000 (rotation term for row) *Typically zero
0.000000000000 (rotation term for column) *Typically zero
-0.010 (size of pixel in y direction)
-95.0000 (x coordinate of centre of upper left pixel in map units)
42.300 (y coordinate of centre of upper left pixel in map units) 

Note that the units of the geo-referencing are in the same units of the projection. Since we are in lat-lon space, the units are decimal degrees. If you were in UTM space, it would probably be meters. For the image generated from my example of nex2img, my world file would look like

   0.01000
   0.00000
   0.00000
  -0.01000
-104.00000
  49.00000

Naming the world file

Depending on your GIS, the naming convention of your world file may be different. Many systems use a generic .wld to describe any world file. Others use variants on the image format nomenclature, for instance, the world file for TIF formated files is .tfw and for PNG is .pngw. For our purposes, we will use .wld.

3.4 Lets pause for a second

If you have made it this far, you are probably wondering what to do with the RASTER image with no political borders or other denotations and this silly 6 line world file. The next section shows an example of taking this image and using the powerful Mapserver to produce a Web Map application. Trust me, this is not the only application of this data.


Next Previous Contents