m.cogo.html 8.04 KB
Newer Older
xuebingbing's avatar
xuebingbing committed
1 2 3
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
xuebingbing's avatar
xuebingbing committed
4
<title>m.cogo - GRASS GIS manual</title>
xuebingbing's avatar
xuebingbing committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="grassdocs.css" type="text/css">
</head>
<body bgcolor="white">
<div id="container">

<a href="index.html"><img src="grass_logo.png" alt="GRASS logo"></a>
<hr class="header">

<h2>NAME</h2>
<em><b>m.cogo</b></em>  - A simple utility for converting bearing and distance measurements to coordinates and vice versa.<BR>
It assumes a cartesian coordinate system
<h2>KEYWORDS</h2>
<a href="miscellaneous.html">miscellaneous</a>, <a href="topic_distance.html">distance</a>, <a href="keywords.html#polar">polar</a>
<h2>SYNOPSIS</h2>
<div id="name"><b>m.cogo</b><br></div>
<b>m.cogo --help</b><br>
<div id="synopsis"><b>m.cogo</b> [-<b>lrc</b>]  [<b>input</b>=<em>name</em>]   [<b>output</b>=<em>name</em>]   [<b>coordinates</b>=<em>east,north</em>]   [--<b>overwrite</b>]  [--<b>help</b>]  [--<b>verbose</b>]  [--<b>quiet</b>]  [--<b>ui</b>] 
</div>

<div id="flags">
<h3>Flags:</h3>
<dl>
<dt><b>-l</b></dt>
<dd>Lines are labelled</dd>

<dt><b>-r</b></dt>
<dd>Convert from coordinates to bearing and distance</dd>

<dt><b>-c</b></dt>
<dd>Repeat the starting coordinate at the end to close a loop</dd>

<dt><b>--overwrite</b></dt>
<dd>Allow output files to overwrite existing files</dd>
<dt><b>--help</b></dt>
<dd>Print usage summary</dd>
<dt><b>--verbose</b></dt>
<dd>Verbose module output</dd>
<dt><b>--quiet</b></dt>
<dd>Quiet module output</dd>
<dt><b>--ui</b></dt>
<dd>Force launching GUI dialog</dd>
</dl>
</div>

<div id="parameters">
<h3>Parameters:</h3>
<dl>
<dt><b>input</b>=<em>name</em></dt>
<dd>Name of input file</dd>
<dd>Default: <em>-</em></dd>

<dt><b>output</b>=<em>name</em></dt>
<dd>Name for output file</dd>
<dd>Default: <em>-</em></dd>

<dt><b>coordinates</b>=<em>east,north</em></dt>
<dd>Starting coordinate pair</dd>
<dd>Default: <em>0.0,0.0</em></dd>

</dl>
</div>
<div class="toc">
<h4 class="toc">Table of contents</h4>
<ul class="toc">
    <li class="toc"><a href="#description" class="toc">DESCRIPTION</a></li>
    <li class="toc"><a href="#notes" class="toc">NOTES</a></li>
    <li class="toc"><a href="#examples" class="toc">EXAMPLES</a></li>
    <li class="toc"><a href="#see-also" class="toc">SEE ALSO</a></li>
    <li class="toc"><a href="#author" class="toc">AUTHOR</a></li>
</ul>
</div>
<h2><a name="description">DESCRIPTION</a></h2>

<em>m.cogo</em> converts data points between bearing and distance
and X,Y coordinates.  Only simple bearing/distance or coordinate
pairs are handled. It assumes a cartesian coordinate system.

<p>
Input can be entered via standard input (default) or from the file
<b>input=</b><em>name</em>. Specifying the input as "-" also
specifies standard input, and is useful for using the program in
a pipeline.  Output will be to standard output unless a file
name other than "-" is specified.  The input file must
closely adhere to the following format, where up to a 10 character
label is allowed but not required (see <b>-l</b> flag).

<p>
<b>Example COGO input:</b>
<div class="code"><pre>
   P23 N 23:14:12 W 340
   P24 S 04:18:56 E 230
   ...
</pre></div>

<p>
The first column may contain a label and you must use the <b>-l</b>
flag so the program knows.  This is followed by a space, and then
either the character 'N' or 'S' to indicate whether the bearing is
relative to the north or south directions.  After another space,
the angle begins in degrees, minutes, and seconds in
"DDD:MM:SS.SSSS" format. Generally, the angle can be of the form
<em>digits + separator + digits + separator + digits [+ '.' + digits]</em>.
A space follows the angle, and is then followed by either the 'E' or 'W'
characters. A space separates the bearing from the distance (which should
be in appropriate linear units).

<p>
<b>Output of the above input:</b>
<div class="code"><pre>
   -134.140211 312.420236 P23
   -116.832837 83.072345 P24
   ...
</pre></div>

<p>
Unless specified with the <b>coord</b> option, calculations begin from (0,0).


<h2><a name="notes">NOTES</a></h2>

For those unfamiliar with the notation for bearings: Picture yourself in the
center of a circle.  The first hemispere notation tell 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 &lt;distance&gt; units in that direction to get to the 
next station.

<p>
<em>m.cogo</em> can be run either non-interactively or
interactively.  The program will be run non-interactively
if the user specifies any parameter or flag. Use "m.cogo -",
to run the program in a pipeline.  Without any flags or
parameters, <em>m.cogo</em> will prompt for each value
using the familiar GRASS parser interface.

<p>
This program is very simplistic, and will not handle deviations
from the input format explained above.  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.

<p>
Lines may be closed by using the <b>-c</b> flag or snapped with
<em>v.clean</em>, lines may be converted to boundaries with <em>v.type</em>,
and closed boundaries may be converted to areas with <em>v.centroids</em>.


<h2><a name="examples">EXAMPLES</a></h2>

<div class="code"><pre>
   m.cogo -l in=cogo.dat
</pre></div>

Where the <tt>cogo.dat</tt> input file looks like:
<div class="code"><pre>
# Sample COGO input file -- This defines an area.
# &lt;label&gt; &lt;bearing&gt; &lt;distance&gt;
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
</pre></div>

<p>
Round trip:
<div class="code"><pre>
   m.cogo -l input=cogo.dat | m.cogo -rl in="-"
</pre></div>

<p>
Import as a vector points map:
<div class="code"><pre>
   m.cogo -l input=cogo.dat | v.in.ascii output=cogo_points x=1 y=2 separator=space
</pre></div>

<p>
Shell script to import as a vector line map:
<div class="code"><pre>
   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
</pre></div>

<p>
Convert that lines map into an area:
<div class="code"><pre>
   # 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
</pre></div>

If necessary, snap the boundary closed with the <em>v.clean</em> module.
Use <tt>tool=snap</tt> and <tt>thresh=0.0001</tt>, or some small value.
<!-- does that need a cat number on the boundary to work? -->


<h2><a name="see-also">SEE ALSO</a></h2>

<em>
<a href="v.centroids.html">v.centroids</a>,
<a href="v.clean.html">v.clean</a>,
<a href="wxGUI.vdigit.html">wxGUI vector digitizer</a>,
<a href="v.in.ascii.html">v.in.ascii</a>,
<a href="v.type.html">v.type</a>
</em>


<h2><a name="author">AUTHOR</a></h2>

Eric G. Miller

<!--
<p>
<i>Last changed: $Date$</i>
--><h2>SOURCE CODE</h2>
<p>Available at: <a href="https://github.com/OSGeo/grass/tree/master/misc/m.cogo">m.cogo source code</a> (<a href="https://github.com/OSGeo/grass/commits/master/misc/m.cogo">history</a>)</p>
<hr class="header">
<p>
<a href="index.html">Main index</a> |
<a href="miscellaneous.html">Miscellaneous index</a> |
<a href="topics.html">Topics index</a> |
<a href="keywords.html">Keywords index</a> |
<a href="graphical_index.html">Graphical index</a> |
<a href="full_index.html">Full index</a>
</p>
<p>
xuebingbing's avatar
xuebingbing committed
250
&copy; 2003-2020
xuebingbing's avatar
xuebingbing committed
251
<a href="http://grass.osgeo.org">GRASS Development Team</a>,
xuebingbing's avatar
xuebingbing committed
252
GRASS GIS 7.8.5 Reference Manual
xuebingbing's avatar
xuebingbing committed
253 254 255 256 257
</p>

</div>
</body>
</html>