maskarray
Overview
maskarray reads an OMG JHC_header 32-bit floating-point (.r4) or 8-bit unsigned char (-8bit) grid and generates an 8-bit binary stencil mask (<infile>.maskmap by default, or -m <maskfile>). Pixels equal to the ignore value (default 0.0) are written as 0, and all valid pixels (!= ignore) are written as 255.
Syntax & CLI Options
maskarray [-8bit] [-ignore <val>] [-m <maskfile>] <bathfile>
| Option | Description | Default |
|---|---|---|
<bathfile> | Required. Input JHC_header .r4 float grid (or 8-bit grid when -8bit is specified). | None |
-8bit | Read <bathfile> as an 8-bit unsigned char array (1 byte/pixel) instead of a 32-bit float array (4 bytes/pixel). | Disabled (32-bit float) |
-ignore <val> | Pixel value in <bathfile> to treat as invalid/nodata (mapped to 0 in the output mask). | 0.0 |
-m <maskfile> | Explicit output filename for the 8-bit mask. | <bathfile>.maskmap |
How It Works
- Reads the
JHC_headerfrom<bathfile>, setsheader.data_type = 1(8-bit), and writes the updated header to the output mask file. - Scans
<bathfile>row-by-row (jswapfloat_freadfor float grids,freadfor-8bitgrids). -
Evaluates each pixel:
*q = (*p != ignore) * 255;writing
0where the input matchesignoreand255everywhere else.
Examples
1. Create a valid-data stencil mask from a bathymetric .r4 grid (where 0.0 is nodata):
maskarray survey.r4
# Creates survey.r4.maskmap
2. Create a stencil mask from an 8-bit sidescan mosaic where 255 represents background nodata:
maskarray -8bit -ignore 255 -m sidescan.mask survey.mos
Workflow Context
- Downstream: Pass the resulting
.maskmaptomix_ci(-mask <maskfile> -ignore 0) to composite sun-illuminated bathymetry over a background sidescan mosaic, satellite image, or land backdrop.