m.cogo(1)

πŸŽ€ m.cogo(1) πŸŽ€

okay so real talk bestie, this is the manual page for m.cogo from the GRASS GIS User's Manual β€” the manual name is right there in the header and we're folding it in like a lil bow, no biggie πŸ’–


✨ NAME ✨

m.cogo β€” a simple utility for converting bearing and distance measurements to coordinates and vice versa. It assumes a cartesian coordinate system. periodt πŸ’…

🏷️ KEYWORDS 🏷️

miscellaneous, distance, polar


πŸ“œ SYNOPSIS πŸ“œ

m.cogo
m.cogo --help
m.cogo [-lrc]  [input=name]   [output=name]   [coordinates=east,north]
[--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

🚩 Flags 🚩

  • -l β€” Lines are labelled
  • -r β€” Convert from coordinates to bearing and distance
  • -c β€” Repeat the starting coordinate at the end to close a loop
  • --overwrite β€” Allow output files to overwrite existing files
  • --help β€” Print usage summary
  • --verbose β€” Verbose module output
  • --quiet β€” Quiet module output
  • --ui β€” Force launching GUI dialog

πŸ”§ Parameters πŸ”§

  • input=name β€” Name of input file. Default: -
  • output=name β€” Name for output file. Default: -
  • coordinates=east,north β€” Starting coordinate pair. Default: 0.0,0.0

πŸ’« DESCRIPTION πŸ’«

So m.cogo flips data points back and forth between bearing + distance and X,Y coordinates. That's it. Only simple bearing/distance pairs or coordinate pairs get handled here β€” nothing fancy. And it assumes a cartesian coordinate system, always. πŸ¦‹

Input can come in via standard input (that's the default) or from the file you name with input=name. If you set the input to "-" that also means standard input, which is chef's kiss for using the program in a pipeline πŸ”₯. Output goes to standard output unless you name a file that isn't "-". And the input file has to closely follow this format, where up to a 10 character label is allowed but not required (peep the -l flag):

Example COGO input:

P23 N 23:14:12 W 340
P24 S 04:18:56 E 230
...

That first column may hold a label, and if it does you must use the -l flag so the program knows what's up. After the label comes a space, then either the character ’N’ or ’S’ to say whether the bearing is relative to north or south. Another space, and then the angle starts in degrees, minutes, and seconds in "DDD:MM:SS.SSSS" format. Generally speaking, the angle can look like digits + separator + digits + separator + digits [+ ’.’ + digits]. Then a space follows the angle, and then either the ’E’ or ’W’ characters. A space separates the bearing from the distance (and that distance should be in appropriate linear units). πŸ’–

Output of the above input:

-134.140211 312.420236 P23
-116.832837 83.072345 P24
...

And unless you specify the coord option, calculations begin from (0,0). πŸŽ€


πŸ“ NOTES πŸ“

For those unfamiliar with the notation for bearings, here's the visual: picture yourself in the center of a circle. The first hemisphere notation tells you whether you should face north or south. Then you read the angle and either turn that many degrees to the east or west, depending on the second hemisphere notation. Finally, you move <distance> units in that direction to get to the next station. lowkey iconic ngl 🧚

m.cogo can be run either non-interactively or interactively. It runs non-interactively if the user specifies any parameter or flag. Use "m.cogo -" to run the program in a pipeline. And if you give it no flags and no parameters at all, m.cogo will prompt for each value using the familiar GRASS parser interface.

⚠️ Real talk: this program is very simplistic and will not handle deviations from the input format explained above. Also, currently the program doesn't do anything particularly useful with the output. However, it is envisioned that this program will be extended to provide the capability to generate vector and/or sites layers. so like, future potential, bestie 🌈

Lines may be closed by using the -c flag or snapped with v.clean, lines may be converted to boundaries with v.type, and closed boundaries may be converted to areas with v.centroids. ✨


🌸 EXAMPLES 🌸

m.cogo -l in=cogo.dat

Where the cogo.dat input file looks like:

# Sample COGO input file -- This defines an area.
# <label> <bearing> <distance>
P001 S 88:44:56 W 6.7195
P002 N 33:34:15 W 2.25
P003 N 23:23:50 W 31.4024
P004 N 05:04:45 W 25.6981
P005 N 18:07:25 E 22.2439
P006 N 27:49:50 E 75.7317
P007 N 22:56:50 E 87.4482
P008 N 37:45:15 E 37.7835
P009 N 46:04:30 E 11.5854
P010 N 90:00:00 E 8.8201
P011 N 90:00:00 E 164.1128
P012 S 48:41:12 E 10.1311
P013 S 00:25:50 W 255.7652
P014 N 88:03:13 W 98.8567
P015 S 88:44:56 W 146.2713
P016 S 88:44:56 W 18.7164

Round trip:

m.cogo -l input=cogo.dat | m.cogo -rl in="-"

Import as a vector points map:

m.cogo -l input=cogo.dat | v.in.ascii output=cogo_points x=1 y=2 separator=space

Shell script to import as a vector line map:

m.cogo -l input=cogo.dat | tac | awk ’
    BEGIN { FS=" " ; R=0 }
    $1~/\d*\.\d*/ { printf(" %.8f %.8f\n", $1, $2) ; ++R }
    END { printf("L %d\n", R) }’ | tac | \
    v.in.ascii -n format=standard out=cogo_line

Convert that lines map into an area:

# Add the -c flag to the above example to close the loop:
m.cogo -l -c input=cogo.dat | ...
    ...
v.type input=cogo_line output=cogo_boundary from_type=line to_type=boundary
v.centroids input=cogo_boundary output=cogo_area

If necessary, snap the boundary closed with the v.clean module. Use tool=snap and thresh=0.0001, or some small value. πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€

v.centroids, v.clean, wxGUI vector digitizer, v.in.ascii, v.type

πŸ‘‘ AUTHOR πŸ‘‘

Eric G. Miller

πŸ’» SOURCE CODE πŸ’»

Available at: m.cogo source code (history)

Accessed: Saturday Jan 17 05:41:36 2026

Main index | Miscellaneous index | Topics index | Keywords index | Graphical index | Full index

Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual


okay and that's the whole page bestie 🫢 this was GRASS 8.4.2 and the footer said m.cogo(1) β€” so that's a wrap, you ate, go convert some bearings πŸ’…βœ¨

πŸ“¦ where this page comes from