8bit2acres
Description
8bit2acres converts raw headerless 8-bit greyscale rasters, raw 32-bit floating-point arrays (-float), Netpbm .pgm images (-pgm), or 1160-column raw GLORIA scanline files (-isgloria) into the Ocean Mapping Groupβs OMG1 (JHC_header, historically ACRES) georeferenced array format. It supports byte-offset skipping (-offset), row/column inversion (-flip, -invert), and optional geographic or projected bounding-box metadata.
CLI Options & Usage
8bit2acres -in <rawimage> -out <acresimage> [-pgm] [-rows <n> -cols <n>] \
[-offset <bytes>] [-float] [-isgloria] [-invert] [-flip] \
[-tlon <deg> -tlat <deg> -blon <deg> -blat <deg> -dx <m> -dy <m>]
-in <filename>: Input raw raster or.pgmfile.-out <filename>: OutputOMG1(JHC_header) file.-pgm: Parses image dimensions (cols,rows) and max grey value directly from aP5binary PGM header.-rows <n> -cols <n>: Explicit dimensions for headerless raw files (required unless-pgmis set).-offset <bytes>: Skips<bytes>at the start of the input file before reading raster lines.-float: Treats input pixels as 4-byte floats (data_type = 3) instead of 1-byte unsigned chars (data_type = 1).-isgloria: Extracts a 992-column swath from 1160-byte raw GLORIA records (skipping the 64-byte header on each row).-invert: Inverts 8-bit pixel intensities (val = 255 - val, mapping0to254).-flip: Reverses the vertical row order (bottom-to-top to top-to-bottom).-tlon,-tlat,-blon,-blat,-dx,-dy: Populates geographic bounds and pixel spacing in the outputJHC_header(projection = GEOGRAPHICif bounds are given withoutdx/dy, orMERCATORwhendx/dyare also supplied).
Algorithm
- Initializes a 1024-byte
OMG1JHC_headerstructure viajhc_init_header()withxmin = 0,xmax = cols,ymin = 0,ymax = rows. - If
-pgmis specified, reads theP5header (skipping#comment lines) to determinecols,rows, and the byte offset to the binary payload. - Reads the input raster (applying
-offsetor-isgloriarow slicing), optionally reverses row order (-flip) or inverts greyscale values (-invert), and writes theJHC_headerfollowed by the raster payload viajhc_write_header().