Creating a new mask based on a polygon of geographical positions

The clipping method (by Frank Sielmann and Silke Schubert) needs a global gridded data file of format netCDF or SERVICE as input to produce a mask in the same resolution and format.

Additionally an ascii file is needed, containing geographical positions (pairs of longitude and latitude values) of the border of the area to mask.

The new mask is given, based on the resolution and format of the input data, as fractional values [0;1], where 1 indicates grid cells inside the area and 0 grid cells outside the area.

For computation a Gaussian grid is assumed with resolution given by the input file. Each gridbox is divided into 50 times 50 sub-gridboxes, for each to decide if inside or outside the polygon bordered area. So the precision of the fractional values of the new mask is 0.0004.


As an example a netCDF file of resolution 192x96 (longitudes x latitudes) is given and a polygon with 15 positions.



A tcsh shell script is available, well documented and easy to use. It prepares the input for the polygon2mask program, runs it, and does a plot of the resulting mask (as shown above).
The file containing the polygon needed as input for the polygon2mask program has to have the westernmost position of each polygon given at its first position.
A program (polysort) to sort the positions of the input file accordingly is also available.
Please contact Silke Schubert.


Input data in Service or netCDF format,
Polygon longitude/latitude positions in ascii format, one position per line, gfortran, CDO, grads (only for quick look at the result)