plotProfile
Overview
plotProfile extracts a cross-sectional profile along a straight line between two pixel coordinates (-start <sx> <sy> and -end <ex> <ey>) from either a 32-bit floating-point (.r4) or 8-bit (.8bit) JHC_header grid. It outputs both a framed, grid-lined vector plot (plot.meta by default, or -outfile <file.meta>) and a 2-column ASCII listing (plot.list containing distance_m value).
Syntax & CLI Options
plotProfile [OPTIONS] -start <sx> <sy> -end <ex> <ey> [-outfile <file.meta>] <infile>
| Option | Description | Default |
|---|---|---|
<infile> | Required. Input JHC_header .r4 (data_type == 3) or .8bit (data_type == 1) grid file. | None |
-start <sx> <sy> | Required. Starting pixel coordinates (X, Y) of the profile line. | None |
-end <ex> <ey> | Required. Ending pixel coordinates (X, Y) of the profile line. | None |
-yrange <Ymin> <Ymax> | Vertical axis range (depth or digital number) for the output plot. | -60.0 0.0 |
-point | Plot discrete crosshair symbols at each sampled pixel along the profile instead of a continuous connected polyline. | Disabled (connected polyline) |
-outfile <filename> | Output plotlib metafile filename. | plot.meta |
-v | Enable verbose flag. | Disabled |
How It Works
- Plot Frame & Grid Lines: Opens an $18 \times 10$ unit
plotlibcanvas (plot.meta) and draws labeled vertical distance grid lines every1000 mand horizontal depth/value grid lines every50units across[Ymin, Ymax]. - Bresenham/Linear Ray Stepping:
- Computes
x_range = |start_x - end_x|,y_range = |start_y - end_y|, and total metric lengthdistance = sqrt(x_range^2 + y_range^2) * JHChead.xstep. - Steps pixel-by-pixel along the dominant axis (
Xifx_range > y_range, elseY), seeking directly to byte offset1024 + 4*(Xpos + Ypos*Dx)(for.r4) or1024 + (Xpos + Ypos*Dx)(for.8bit).
- Computes
- Output Generation: For every sampled point whose
(xpos, ypos)falls inside the plot box, writesxval yval(metric distance and grid value) toplot.listand draws either a line segment or crosshair (-point) in theplotlibmetafile.
Examples
Extract and plot a bathymetric cross-section between pixel (100, 250) and (850, 600):
plotProfile -yrange -120 -10 -start 100 250 -end 850 600 -outfile canyon_prof.meta canyon.r4
# Also writes 2-column ASCII profile to plot.list
Workflow Context
- See Also:
extractProfileandextractNodeProffor non-graphical profile extraction, andlocate_fixto convert geographic(lat, lon)endpoints into pixel(sx, sy)coordinates.