nbspgislib

Rad Tutorial

In this tutorial we will use nbspradgis to convert a nexrad nids file to shapefile (shp) format that we will then use with the shp2img program (from the mapserver package) to create an image as shown in these samples. The following steps are involved:

We will cover each step one by one.

Obtaining the raw data

There are several ways to obtain the satellite data files. We will use OpenNoaaport as the data source. We will use a radar file from the San Juan site, which are named like n0rjua_20110213_1804.nids. For the purpose of this tutorial we can just execute

wget http://www.opennoaaport.net:8015/digatmos/nexrad/nids/jua/n0r/latest

to retrieve the most recent n0rjua file.

Converting the data

We will cover first the conversion of the legacy 4-bit files (e.g., n0r, n1r, ...) and consider at the end the newer 8-bit version (e.g., n0q, n1q, ...).

The n0r data files are compressed, in a particular way, with zlib. On the other hand, the nbspradgis program operates on the original, uncompressed, nids data. We therefore use the nbspunz program, (which is part of the NbspGislib package) to uncompress the raw data file before operating on it with nbspradgis. Furthermore, the uncompressed nids file contains two headers (the WMO and CCB headers) that are not part of the nids data and must be removed before passing it to nbspradgis. In one stroke, the command

nbspunz -C latest | nbspradgis

will produce four files, named in our example,

The -C option to nbspunz instructs it to cut the WMO and CCB headers from the output, as we have indicated above. The shp, shx and dbf are the usual binary files associated with shapefiles, while the info file is a text file that can be opened with any editor. It contains some information that is useful for the map script, such as the lat/lon coordinates of the radar site and the size of the bounding box (bb). In the example above, the content of the file is

radseconds: 1297637504
radmode: 2
prodcode: 19
packetcode: 44831
lon: -66.078
lat: 18.116
height: 2958
bb: -67.855937 16.572021 -64.631014 18.896376

Using the shapefile data file to create the image

The final step is to create the image from the shp file. The main ingredient besides the data file itself is the map script that will be used by the shp2img program. The map script contains, among other parameters, the following

EXTENT -67.855937 16.572021 -64.631014 18.896376
SIZE 800 800

where the extent has been set according to the bb value from the info file shown above, while the size parameter is essentially arbitrary.

The image is then produced by executing

shp2img -m bref.map -o n0rjua.png

The nbspragis tutorials and examples contain map script(s), data file(s) and other auxiliary files (e.g., the (shape) data files to generate the country and state map outlines) to reproduce the above example and several others.

Note about the new 8 bit data files

In contrast with the legacy data files, such as the n0r, n1r and so on, the newer 8 bit version are compressed with the bzip2 library instead of the zlib library. More important for our purposes here, the nbspradgis can uncompress those files itself without using nbspunz first. Therefore, if we download one such file

wget http://www.opennoaaport.net:8015/digatmos/nexrad/nids/jua/n0q/latest

the appropriate command to execute to produce the shapefile-related data files is simply

nbspradgis latest

and similarly for the n1q and the other 8 bit files. This will create the shapefile data files mentioned above, and the remaining steps are the same.