changeAspect
Description
changeAspect independently rescales the horizontal (X) and vertical (Y) pixel dimensions of an 8-bit (data_type = 1) or 32-bit floating-point (data_type = 3, .r4) OMG1 (JHC_header) array. It accepts either multiplicative scale factors (-xfactor, -yfactor) or explicit target pixel dimensions (-xdim, -ydim), updating the headerβs grid spacing (dx, dy) to preserve geographic scale.
CLI Options & Usage
changeAspect -in <infile> -out <outfile> \
[-xfactor <fx>] [-yfactor <fy>] [-xdim <nx>] [-ydim <ny>]
-in <infile>: Input 8-bit or 32-bit floatOMG1raster file.-out <outfile>: Output rescaledOMG1raster file.-xfactor <fx>/-yfactor <fy>: Floating-point multiplier for column count (xmax) and row count (ymax) (default:1.0).-xdim <nx>/-ydim <ny>: Explicit target column count and/or row count (overrides-xfactor/-yfactorby settingxfactor = xdim / xmax,yfactor = ydim / ymax).
Algorithm
- Reads the
JHC_headerfrom<infile>, computes new dimensionsnew_x = xmax * xfactorandnew_y = ymax * yfactor, and scales pixel sizesdx /= xfactor,dy /= yfactor. - For 8-bit images (
data_type == 1): Performs inverse nearest-neighbor coordinate mapping (old_i = i / xfactor,old_j = j / yfactor) across thenew_x Γ new_ygrid. - For 32-bit float grids (
data_type == 3): Performs a two-stage separable resampling (intermediate[xmax * new_y]along Y, thenfinal[new_x * new_y]along X). When downsampling (factor < 1.0), averages all valid (!= 99999.0) source cells falling within each output cell; when upsampling (factor >= 1.0), uses nearest-neighbor replication.