Skip to end of metadata
Go to start of metadata

There are keys to allow the user to extract an area from BUFR data:

  • extractAreaNorthLatitude
  • extractAreaSouthLatitude
  • extractAreaWestLongitude
  • extractAreaEastLongitude
  • extractAreaLongitudeRank
  • doExtractArea
  • extractedAreaNumberOfSubsets

This is implemented for both compressed and uncompressed data.

To explain the use of these keys the following example using the bufr_filter is provided, but please note that these same keys can be set using the Fortran and Python interfaces as well and no special functions have been implemented in the bufr_filter for this feature.

The following file "extract.filter" with bufr_filter can be used to perform the extraction of subsets from a BUFR message:

transient originalNumberOfSubsets = numberOfSubsets;
set unpack=1;
set extractAreaNorthLatitude=52.5;
set extractAreaSouthLatitude=51.1;
set extractAreaWestLongitude=155.2;
set extractAreaEastLongitude=160.5;
set extractAreaLongitudeRank=1;

set doExtractArea=1; # This does an implicit 'pack'

if (extractedAreaNumberOfSubsets != 0) {

print "extracted [extractedAreaNumberOfSubsets] of [originalNumberOfSubsets] subsets";

In line 1 we record the current (original) number of subsets. In lines 3 and 4 we specify the north and south latitudes of the bounding box and in lines 5 and 6 we specify the west and east longitudes.
The area extraction criteria are applied by default to latitude and longitude keys with rank=1, but this can be modified using the keys extractAreaLongitudeRank and extractAreaLatitudeRank. As an example if extractAreaLongitudeRank=2 the boundaries for longitude are applied to #2#longitude not to #1#longitude.
Finally in lines 9 to 13 we do the actual extraction and write out the message to the output BUFR file. The output will have just those subsets whose bounds are included in the latitude/longitude specification above (Note: the extraction is made including the box boundaries)

The final print message informs the user how many subsets were actually extracted during this process out of the original set.  No output BUFR is written (the "write" statement not executed) unless there was at least one extracted subset.

This example can be used on any multi-subset input file in compressed form as follows:

> bufr_filter -o out.bufr extract.filter in.bufr