1m.cogo(1) GRASS GIS User's Manual m.cogo(1)
2
3
4
6 m.cogo - A simple utility for converting bearing and distance measure‐
7 ments to coordinates and vice versa.
8 It assumes a cartesian coordinate system
9
11 miscellaneous, distance, polar
12
14 m.cogo
15 m.cogo --help
16 m.cogo [-lrc] [input=name] [output=name] [coordinates=east,north]
17 [--overwrite] [--help] [--verbose] [--quiet] [--ui]
18
19 Flags:
20 -l
21 Lines are labelled
22
23 -r
24 Convert from coordinates to bearing and distance
25
26 -c
27 Repeat the starting coordinate at the end to close a loop
28
29 --overwrite
30 Allow output files to overwrite existing files
31
32 --help
33 Print usage summary
34
35 --verbose
36 Verbose module output
37
38 --quiet
39 Quiet module output
40
41 --ui
42 Force launching GUI dialog
43
44 Parameters:
45 input=name
46 Name of input file
47 Default: -
48
49 output=name
50 Name for output file
51 Default: -
52
53 coordinates=east,north
54 Starting coordinate pair
55 Default: 0.0,0.0
56
58 m.cogo converts data points between bearing and distance and X,Y coor‐
59 dinates. Only simple bearing/distance or coordinate pairs are handled.
60 It assumes a cartesian coordinate system.
61
62 Input can be entered via standard input (default) or from the file in‐
63 put=name. Specifying the input as "-" also specifies standard input,
64 and is useful for using the program in a pipeline. Output will be to
65 standard output unless a file name other than "-" is specified. The
66 input file must closely adhere to the following format, where up to a
67 10 character label is allowed but not required (see -l flag).
68
69 Example COGO input:
70 P23 N 23:14:12 W 340
71 P24 S 04:18:56 E 230
72 ...
73
74 The first column may contain a label and you must use the -l flag so
75 the program knows. This is followed by a space, and then either the
76 character ’N’ or ’S’ to indicate whether the bearing is relative to the
77 north or south directions. After another space, the angle begins in
78 degrees, minutes, and seconds in "DDD:MM:SS.SSSS" format. Generally,
79 the angle can be of the form digits + separator + digits + separator +
80 digits [+ ’.’ + digits]. A space follows the angle, and is then fol‐
81 lowed by either the ’E’ or ’W’ characters. A space separates the bear‐
82 ing from the distance (which should be in appropriate linear units).
83
84 Output of the above input:
85 -134.140211 312.420236 P23
86 -116.832837 83.072345 P24
87 ...
88
89 Unless specified with the coord option, calculations begin from (0,0).
90
92 For those unfamiliar with the notation for bearings: Picture yourself
93 in the center of a circle. The first hemispere notation tell you
94 whether you should face north or south. Then you read the angle and
95 either turn that many degrees to the east or west, depending on the
96 second hemisphere notation. Finally, you move <distance> units in that
97 direction to get to the next station.
98
99 m.cogo can be run either non-interactively or interactively. The pro‐
100 gram will be run non-interactively if the user specifies any parameter
101 or flag. Use "m.cogo -", to run the program in a pipeline. Without any
102 flags or parameters, m.cogo will prompt for each value using the famil‐
103 iar GRASS parser interface.
104
105 This program is very simplistic, and will not handle deviations from
106 the input format explained above. Currently, the program doesn’t do
107 anything particularly useful with the output. However, it is envi‐
108 sioned that this program will be extended to provide the capability to
109 generate vector and/or sites layers.
110
111 Lines may be closed by using the -c flag or snapped with v.clean, lines
112 may be converted to boundaries with v.type, and closed boundaries may
113 be converted to areas with v.centroids.
114
116 m.cogo -l in=cogo.dat
117 Where the cogo.dat input file looks like:
118 # Sample COGO input file -- This defines an area.
119 # <label> <bearing> <distance>
120 P001 S 88:44:56 W 6.7195
121 P002 N 33:34:15 W 2.25
122 P003 N 23:23:50 W 31.4024
123 P004 N 05:04:45 W 25.6981
124 P005 N 18:07:25 E 22.2439
125 P006 N 27:49:50 E 75.7317
126 P007 N 22:56:50 E 87.4482
127 P008 N 37:45:15 E 37.7835
128 P009 N 46:04:30 E 11.5854
129 P010 N 90:00:00 E 8.8201
130 P011 N 90:00:00 E 164.1128
131 P012 S 48:41:12 E 10.1311
132 P013 S 00:25:50 W 255.7652
133 P014 N 88:03:13 W 98.8567
134 P015 S 88:44:56 W 146.2713
135 P016 S 88:44:56 W 18.7164
136
137 Round trip:
138 m.cogo -l input=cogo.dat | m.cogo -rl in="-"
139
140 Import as a vector points map:
141 m.cogo -l input=cogo.dat | v.in.ascii output=cogo_points x=1 y=2 separator=space
142
143 Shell script to import as a vector line map:
144 m.cogo -l input=cogo.dat | tac | awk ’
145 BEGIN { FS=" " ; R=0 }
146 $1~/\d*\.\d*/ { printf(" %.8f %.8f\n", $1, $2) ; ++R }
147 END { printf("L %d\n", R) }’ | tac | \
148 v.in.ascii -n format=standard out=cogo_line
149
150 Convert that lines map into an area:
151 # Add the -c flag to the above example to close the loop:
152 m.cogo -l -c input=cogo.dat | ...
153 ...
154 v.type input=cogo_line output=cogo_boundary from_type=line to_type=boundary
155 v.centroids input=cogo_boundary output=cogo_area
156 If necessary, snap the boundary closed with the v.clean module. Use
157 tool=snap and thresh=0.0001, or some small value.
158
160 v.centroids, v.clean, wxGUI vector digitizer, v.in.ascii, v.type
161
163 Eric G. Miller
164
166 Available at: m.cogo source code (history)
167
168 Accessed: Saturday Jan 21 20:40:27 2023
169
170 Main index | Miscellaneous index | Topics index | Keywords index |
171 Graphical index | Full index
172
173 © 2003-2023 GRASS Development Team, GRASS GIS 8.2.1 Reference Manual
174
175
176
177GRASS 8.2.1 m.cogo(1)