The forum is locked.

The Ocean Color Forum has transitioned over to the Earthdata Forum (https://forum.earthdata.nasa.gov/). The information existing below will be retained for historical reference. Please sign into the Earthdata Forum for active user support.

Up Topic Products and Algorithms / Satellite Data Products & Algorithms / MSl12 land mask files (locked)
- By Nancy Date 2004-05-24 01:57
Hello,
    I'd like to know the details about the two data files '$SEADAS/data/landmask.dat' and '$SEADAS/data/landmask_dilated_25.dat', i.e. the header file information of the two files.
     Look forward to your reply.
     Thanks a lot!

Nancy
- By bryanfranz Date 2004-05-24 15:18
Nancy,

The landmask files are 128x128 pixels per degree resolution, bit encoded into a structured array.  The dilated land mask is only used for seawifs land processing, to ensure that land and mixed land/water get processed to surface reflectance.  The code which reads these files (and the bathymetry mask) is $SEADAS/src/c_procs/msl12/b128_msk_get.c.  A detailed description and Perl script for reading the files (both provided by Norman Kuring) follows.

-- bryan

The file is organized in 2048-byte records.
The first record contains the following metadata stored
as 16-bit signed integers.

Byte range      Value   Description
----------      -----   --------------------------------------------
   0 -  1         128   Mask resolution i.e. 128th-of-a-degree units
   2 -  3        7701   Number of 2048-byte records in the file
   4 -  5        2048   Record length in bytes
   8 -  9        -180   Western boundary of the mask
  10 - 11         180   Eastern boundary of the mask
  12 - 13         -90   Southern boundary of the mask
  14 - 15          90   Northern boundary of the mask

The second through the sixty-fifth records of the file contain
64800 16-bit integers that correspond to one-degree-squares on
a Plate Carree (cylindrical equirectangular) projection of the
earth's surface.  The first integer corresponds to the square
centered at 89.5 degrees South and 179.5 degrees West (-89.5, -179.5).
Subsequent integers correspond to map squares as one moves to the
right (east) and up (north) across the map by rows.  Thus the
sequence is:

(-89.5, -179.5), (-89.5, -178.5), (-89.5, -177.5), ...,
..., (89.5, 176.5), (89.5, 177.5), (89.5, 178.5), (89.5, 179.5) .

If the integer that corresponds to a given one-degree square equals
1, then the entire square is over land.  If it equals 0, then none
of the represented area contains any land.  Any number besides 0
or 1 should be an integer greater than or equal to 65 referring to
the 2048-byte record in the file that contains the high-resolution
bitmap for the land distribution in that particular map square.
(The record numbers are zero-based such that, for example, record
number 65 points to the 66th 2048-byte record in the file.)

Each record from the sixty-sixth onward contains a bitmap for
a particular one-degree square as described above.  Each bitmap
is 128 bits wide by 128 bits high and fits exactly into a 2048-byte
record.  The ordering of the bits in the record is the same as
the ordering of the 64800 integers described above, namely, from
the southwest corner by rows to the northeast corner.  If a bit
is set, then the referenced 128th-of-a-degree square is to be
interpreted as land; otherwise, the area is water.

In the current file, lakes are masked as land.

I have put a short perl script in this directory that will
extract a portion of the mask as a portable bitmap (pbm) file.
See mask128topbm.pl .

Norman Kuring                                   12-May-1997

#!/usr/freeware/bin/perl

$north = 45;
$south = 39;
$west = -74;
$east = -68;

$width  = ( $east - $west ) * 128;
$height = ($north - $south) * 128;

open F, "mask128.dat" or die;
seek F, 2048, 0 or die;
read(F, $data, 129600) == 129600 or die;
@data = unpack "s*", $data;
$allland = chr(0xFF) x 16;
$noland  = chr(   0) x 16;
for($i=179, $j=0; $i>=0; $i--, $j+=360){
   $lowres[$i] = [@data[$j .. $j + 359]];
}

print "P4\n$width $height\n";

for($i = 90 - $north; $i < 90 - $south; $i++){
   for($k = 127; $k >= 0; $k--){
     for($j = $west + 180; $j < $east + 180; $j++){
       if($lowres[$i][$j] == 0){
         print $noland;
       }
       elsif($lowres[$i][$j] == 1){
         print $allland;
       }
       else{
         seek F, ($lowres[$i][$j] * 2048 + $k * 16), 0 or die;
         read(F, $hires, 16) == 16 or die;
         print $hires;
       }
     }
   }
}
- By bryanfranz Date 2004-05-26 13:43
We've posted a file format spec for the labd and bathymetry files here:

  http://oceancolor.gsfc.nasa.gov/DOCS/ODPS_Land_Mask.pdf
Up Topic Products and Algorithms / Satellite Data Products & Algorithms / MSl12 land mask files (locked)