locate_fix
Overview
locate_fix converts coordinates between geographic coordinates (lat, lon) and pixel coordinates (pixX, pixY) on an existing OMG JHC_header mapsheet (-map <file>). It can run interactively (prompting for coordinates on stdin) or in batch file mode (-in <datafile>, writing converted 3-column records to <datafile>.gridvals).
Syntax & CLI Options
locate_fix [OPTIONS] -map <area.base> [-in <datafile>]
| Option | Description | Default |
|---|---|---|
-map <filename> | Required. Existing OMG JHC_header file (.r4, .8bit, .blank, .mos) defining the projection, ellipsoid, bounds, and resolution (xstep, ystep). | None |
-geo2pix | Convert geographic coordinates (lat, lon) to grid pixel coordinates (pixX, pixY) using Project(). | Default (geo2pix = 1) |
-pix2geo | Convert grid pixel coordinates (pixX, pixY) to geographic coordinates (lat, lon) and projected northing/easting using inv_proj(). | Disabled |
-decdeg | In interactive -geo2pix mode, prompt for decimal degrees (lat lon) instead of degrees and decimal minutes (latdeg min londeg min). (Note: batch -in mode always reads decimal degrees). | Disabled (deg min in interactive mode) |
-in <filename> | Batch mode: read 3-column ASCII records (lat lon depth for -geo2pix, or pixX pixY depth for -pix2geo) from <filename> and write converted records to <filename>.gridvals. | Interactive stdin mode |
-skip <N> | In batch -in mode, decimate output by writing only every N-th valid point (in % skip == 0). | 1 (write all) |
-flip_depth | Negate the 3rd column (-rdepth) when writing <filename>.gridvals. | Disabled |
-v | Enable verbose output of every coordinate transformation. | Disabled |
How It Works
- Header Inspection: Opens
-mapand reads its 1024-byteJHC_header(get_print_JHC_header), supporting all OMG projections (Mercator, UTM, Unprojected Geographic, Rotated UTM, Rotated Mercator, Lambert). - Interactive Mode (when
-inis omitted):- Prompts the user for
latdeg min, londeg min(orlat lonif-decdegis set, orpixX pixYif-pix2geois set). - Calls
Project(lon, lat, &x, &y, &header)orinv_proj(x, y, &lon, &lat, &easting, &northing, &header)and prints the result alongside the grid resolution (mpp). Repeats while the user answersy.
- Prompts the user for
- Batch File Mode (
-in <filename>):- Reads triples (
%lf %lf %f) from<filename>. - In
-geo2pixmode, projects(lon, lat)to(x, y)and filters out points falling outside the mapsheet (0 <= x < dxand0 <= y < dy). - Writes
x y depth(orlat lon depthin-pix2geomode) to<filename>.gridvals.
- Reads triples (
Examples
1. Interactive decimal-degree to pixel lookup on a mapsheet:
locate_fix -map survey_area.r4 -decdeg
2. Batch-convert an ASCII lat lon depth file into pixel coordinates within survey_area.r4:
locate_fix -map survey_area.r4 -geo2pix -in cores.llz
# Writes cores.llz.gridvals
3. Batch-convert pixel picks (pixX pixY z) back into geographic lat lon z:
locate_fix -map survey_area.r4 -pix2geo -in picked_features.xy
# Writes picked_features.xy.gridvals
Workflow Context
- Useful for locating core stations, acoustic targets, or profile endpoints in pixel space on an OMG
.r4or.8bitgrid, or converting pixel coordinates picked in an image viewer back tolat/lon.