subimage
Description
subimage extracts a rectangular sub-window (-cols à -rows) from an 8-bit (data_type = 1), 32-bit floating-point (-float, data_type = 3), or raw headerless (-raw) raster. The crop window can be specified either by upper-left pixel coordinates (-left_x, -top_y) or centered on a geographic coordinate (-geocentre <lat> <lon>), with automatic recalculation of the OMG1 (JHC_header) geographic bounding box.
CLI Options & Usage
subimage -in <infile> -out <outfile> -rows <nrows> -cols <ncols> \
[-left_x <x0> -top_y <y0> | -geocentre <lat> <lon>] \
[-float] [-georef] [-raw -in_rows <nr> -in_cols <nc>]
-in <infile> -out <outfile>: Input and outputOMG1raster files.-rows <nrows> -cols <ncols>: Height (ymax) and width (xmax) of the extracted sub-image in pixels.-left_x <x0> -top_y <y0>: Upper-left pixel coordinates of the crop window (default:0, 0).-geocentre <lat> <lon>: Centers thecols à rowscrop window on(lat, lon)usingresolve_pixel_from_pos()(x0 = px - cols/2,y0 = py - rows/2).-float: Extracts 4-byte floating-point (data_type = 3,.r4) cells (filling out-of-bounds padding with99999.0instead of255).-georef: Forces Mercator bounding-box recalculation (merc_to_geog) fromleft_x,top_y,dx, anddy.-raw -in_rows <nr> -in_cols <nc>: Reads a headerless raw 8-bit raster of dimensionsnc à nrand wraps the extracted sub-window in anOMG1header.
Algorithm
- Reads the input
JHC_header(or initializes one if-rawis set) and resolves(left_x, top_y). - Calls
resolve_pos_from_pixel()at(left_x, top_y)and(left_x + cols, top_y + rows)to update(tlat, tlon)and(blat, blon)in the outputJHC_header. - Copies pixels inside
[left_x .. left_x + cols - 1, top_y .. top_y + rows - 1]into the output buffer (padding any overhang beyond the source borders with255or99999.0) and writes<outfile>.