| 1 |
<h2>DESCRIPTION</h2> |
| 2 |
|
| 3 |
This program allows a user to convert coordinates from one projection |
| 4 |
to another. Coordinates can be read from one file, converted, and |
| 5 |
results written to another file. Alternatively, if the <b>input=-</b>, |
| 6 |
eastings and northings may be passed to the program directly from |
| 7 |
standard input. If the <b>output</b> option is omitted, the results |
| 8 |
are sent directly to standard output. In this way <em>m.proj</em> can |
| 9 |
be used as a simple frontend to |
| 10 |
the <a href="https://proj.org/apps/cs2cs.html">PROJ</a> |
| 11 |
<em>cs2cs</em> utility. The <b>-i</b> or <b>-o</b> flags make the task |
| 12 |
especially easy for the common problem of converting to or from lat/long |
| 13 |
WGS84. |
| 14 |
<p> |
| 15 |
<i>Note</i>: This program does not transform GRASS maps, it is |
| 16 |
designed to determine the equivalent coordinate values of an |
| 17 |
individual position or list of |
| 18 |
positions. Use <em><a href="v.proj.html">v.proj</a></em> to reproject |
| 19 |
vector maps or <em><a href="r.proj.html">r.proj</a></em> for raster maps. |
| 20 |
<p> |
| 21 |
For an introduction to map projections (with PROJ),see the manual page of |
| 22 |
<a href="r.proj.html">r.proj</a>. |
| 23 |
|
| 24 |
<h2>NOTES</h2> |
| 25 |
|
| 26 |
<em>cs2cs</em> expects input data to formatted as <code>x y</code>, so if |
| 27 |
working with latitude-longitude data be sure to send the <code>x</code> |
| 28 |
value first, i.e., <code>longitude latitude</code>. Output data will |
| 29 |
be exported using the same convention. |
| 30 |
<p> |
| 31 |
<em>cs2cs</em> will treat a third data column as a <code>z</code> value |
| 32 |
(elevation) and will modify the value accordingly. This usually |
| 33 |
translates into small but real differences in that data column. |
| 34 |
<p> |
| 35 |
<em>cs2cs</em> does not expect the input stream to contain column |
| 36 |
headings, only numbers. If your data file has lines you wish to have |
| 37 |
passed through without being processed, they must start with the |
| 38 |
'<code>#</code>' character. |
| 39 |
<p> |
| 40 |
If sending <em>m.proj</em> data from standard input, be aware that the |
| 41 |
data is first stored to a temporary file before being processed |
| 42 |
with <em>cs2cs</em>. It is therefore not advisable to |
| 43 |
send <em>m.proj</em> data from an open data stream. The module will |
| 44 |
stop listening for incoming data after 2 seconds of inactivity. You |
| 45 |
may use the projection parameters gleaned from <em>m.proj</em>'s |
| 46 |
verbose mode (<b>--verbose</b>) with <em>cs2cs</em> directly in this case. |
| 47 |
<p> |
| 48 |
Custom projection parameters can be used via the <b>proj_in</b> and |
| 49 |
<b>proj_out</b> options. Full documentation of the projection |
| 50 |
parameter format may be found on |
| 51 |
the <a href="https://proj.org">PROJ</a> website. Using |
| 52 |
these options will fully override the default parameters the module |
| 53 |
would normally use. |
| 54 |
<p> |
| 55 |
By using the <b>--verbose</b> verbose flag, the user can see exactly |
| 56 |
what projection parameters will be used in the conversion as well as |
| 57 |
some other informative messages. |
| 58 |
<p> |
| 59 |
If output is to lat/long, it will be formatted using PROJ's |
| 60 |
Degree:Minute:Second (DMS) convention |
| 61 |
of <code>DDDdMM'SSS.SS"H</code>. This can be handy if you wish to quickly |
| 62 |
convert lat/long decimal degree data into its DMS equivalent.<br> |
| 63 |
Alternatively, to have <em>m.proj</em> output data in decimal degrees, |
| 64 |
use the <b>-d</b> flag. This flag can also be used with non-lat/long |
| 65 |
data to force a higher number of decimal places (the <em>cs2cs</em> |
| 66 |
default is 2). |
| 67 |
<p> |
| 68 |
Note that Lat/long output can be converted to GRASS's DMS convention |
| 69 |
(<code>DDD:MM:SSS.SSSH</code>) by piping the results of <em>m.proj</em> |
| 70 |
through the <em>sed</em> stream editor as follows. |
| 71 |
|
| 72 |
<div class="code"><pre> |
| 73 |
m.proj -o ... | sed -e 's/d/:/g' -e "s/'/:/g" -e 's/"//g' |
| 74 |
</pre></div> |
| 75 |
|
| 76 |
<h2>EXAMPLES</h2> |
| 77 |
|
| 78 |
The examples are suitable for the North Carolina sample dataset if not |
| 79 |
stated otherwise: |
| 80 |
|
| 81 |
<h3>Reproject vector point coordinate pairs to Long/Lat WGS84</h3> |
| 82 |
|
| 83 |
<p> |
| 84 |
The <em>m.proj</em> module is designed to work seamlessly with point |
| 85 |
data exported from the GIS |
| 86 |
with <em><a href="v.out.ascii.html">v.out.ascii</a></em>, as the |
| 87 |
following example shows. |
| 88 |
|
| 89 |
<div class="code"><pre> |
| 90 |
# Long/Lat WGS84 output in DMS |
| 91 |
v.out.ascii bridges | m.proj -o input=- |
| 92 |
|
| 93 |
# Long/Lat WGS84 output in decimal degree |
| 94 |
v.out.ascii bridges | m.proj -o -d input=- |
| 95 |
</pre></div> |
| 96 |
|
| 97 |
<h3>Reproject Long/Lat WGS84 coordinate pair to current map projection</h3> |
| 98 |
|
| 99 |
To convert a Long/Lat WGS84 coordinate pair to the current map CRS |
| 100 |
using the <b>-i</b> flag which sets the target projection parameters |
| 101 |
automatically from the current project definition: |
| 102 |
<div class="code"><pre> |
| 103 |
echo "-78.61168178 33.92225767" | m.proj -i input=- |
| 104 |
645513.47|19180.31|0.00 |
| 105 |
</pre></div> |
| 106 |
|
| 107 |
<p> |
| 108 |
The same, but load points from a file named <code>waypoints.txt</code> and |
| 109 |
continue on to import the results into a GRASS vector points map in |
| 110 |
the current map projection: |
| 111 |
<div class="code"><pre> |
| 112 |
# check file content |
| 113 |
cat waypoints.txt |
| 114 |
-78.43977824 33.89587173 |
| 115 |
-78.54944691 33.88964566 |
| 116 |
-78.51078074 33.88141495 |
| 117 |
-77.14037951 35.60543020 |
| 118 |
|
| 119 |
# reproject points and generate vector map on the fly |
| 120 |
m.proj -i input=waypoints.txt | v.in.ascii input=- output=test_pnts |
| 121 |
|
| 122 |
# verify result |
| 123 |
v.db.select test_pnts cat|dbl_1|dbl_2|dbl_3 |
| 124 |
1|661427.74|16329.14|0 |
| 125 |
2|651285.43|15586.79|0 |
| 126 |
3|654867.21|14690.64|0 |
| 127 |
4|778074.58|207402.6|0 |
| 128 |
</pre></div> |
| 129 |
|
| 130 |
<h3>Custom projection parameter usage</h3> |
| 131 |
|
| 132 |
To transform points from a UTM projection (here specified with detailed |
| 133 |
projection definition rather than using an EPSG code) into the |
| 134 |
Gauss-Krüger Grid System, importing from and exporting to files: |
| 135 |
|
| 136 |
<div class="code"><pre> |
| 137 |
m.proj proj_in="+proj=utm +name=utm +a=6378137.0 +es=0.006694380 \ |
| 138 |
+zone=32 +unfact=1.0" proj_out="+proj=tmerc +name=tmerc \ |
| 139 |
+a=6377397.155 +es=0.0066743720 +lat_0=0.0 +lon_0=9.0 +k=1.0 \ |
| 140 |
+x_0=3500000.0" input=utm.coord.txt output=new.gk.coord.txt |
| 141 |
</pre></div> |
| 142 |
|
| 143 |
<p> |
| 144 |
Projection parameters provided in the above case: <code>+proj</code> |
| 145 |
(projection type), <code>+name</code> (projection name), <code>+a</code> |
| 146 |
(ellipsoid: equatorial radius), <code>+es</code> (ellipsoid: |
| 147 |
eccentricity squared), <code>+zone</code> (zone for the area), |
| 148 |
<code>+unfact</code> (conversion factor from meters to other units, |
| 149 |
e.g. feet), <code>+lat_0</code> (standard parallel), <code>+lon_0</code> |
| 150 |
(central meridian), <code>+k</code> (scale factor) and <code>+x_0</code> |
| 151 |
(false easting). Sometimes false northing is needed which is coded as |
| 152 |
<code>+y_0</code>. Internally, the underlying |
| 153 |
<a href="https://proj.org">PROJ</a> projection library |
| 154 |
performs an inverse projection to latitude-longitude and then projects |
| 155 |
the coordinate list to the target projection. |
| 156 |
<p> |
| 157 |
Datum conversions are automatically handled by the PROJ library if |
| 158 |
<code>+datum</code> settings are specified on <b>both</b> the input <b>and</b> output |
| 159 |
projections on the command line. The <code>+towgs84</code> parameter can be used to |
| 160 |
define either 3 or 7 term datum transform coefficients, satisfying this requirement. |
| 161 |
<p>If a datum is specified there is no need for the <code>+ellps=</code> or underlying |
| 162 |
parameters, <code>+a=</code>, <code>+es=</code>, etc. |
| 163 |
|
| 164 |
<p> |
| 165 |
Another custom parameter usage example: |
| 166 |
|
| 167 |
<div class="code"><pre> |
| 168 |
m.proj proj_in="+proj=tmerc +datum=ire65 +lat_0=53.5 +lon_0=-8 +x_0=200000 \ |
| 169 |
+y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt |
| 170 |
</pre></div> |
| 171 |
|
| 172 |
or without datum transformation: |
| 173 |
|
| 174 |
<div class="code"><pre> |
| 175 |
m.proj proj_in="+proj=tmerc +ellps=modif_airy +lat_0=53.5 +lon_0=-8 +x_0=200000 \ |
| 176 |
+y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt |
| 177 |
</pre></div> |
| 178 |
|
| 179 |
<p> |
| 180 |
In this example no datum transformation will take place as a datum was |
| 181 |
not specified for the input projection. The datum specified for the |
| 182 |
output projection will thus be silently ignored and may be left out; |
| 183 |
all that is achieved a simple conversion from projected to geodetic |
| 184 |
co-ordinates, keeping the same datum (and thus also the same |
| 185 |
ellipsoid). |
| 186 |
|
| 187 |
<p> |
| 188 |
For more usage examples, see the documentation for the |
| 189 |
<a href="https://proj.org">PROJ</a> <em>cs2cs</em> program. |
| 190 |
|
| 191 |
<h2>REFERENCES</h2> |
| 192 |
|
| 193 |
<ul> |
| 194 |
<li>Evenden, G.I. |
| 195 |
(1990) <a href="https://pubs.usgs.gov/of/1990/of90-284/ofr90-284.pdf">Cartographic |
| 196 |
projection procedures for the UNIX environment - a user's |
| 197 |
manual</a>. USGS Open-File Report 90-284 (OF90-284.pdf) See |
| 198 |
also there: Interim Report and 2nd Interim Report on Release 4, |
| 199 |
Evenden 1994).</li> |
| 200 |
<li><a href="https://proj.org">PROJ</a> Cartographic Projection Library</li> |
| 201 |
</ul> |
| 202 |
|
| 203 |
<h2>SEE ALSO</h2> |
| 204 |
|
| 205 |
<em> |
| 206 |
<a href="g.proj.html">g.proj</a>, |
| 207 |
<a href="r.proj.html">r.proj</a>, |
| 208 |
<a href="v.proj.html">v.proj</a>, |
| 209 |
<a href="i.rectify.html">i.rectify</a>, |
| 210 |
<a href="v.in.ascii.html">v.in.ascii</a>, |
| 211 |
<a href="v.out.ascii.html">v.out.ascii</a> |
| 212 |
</em> |
| 213 |
|
| 214 |
<h2>AUTHOR</h2> |
| 215 |
|
| 216 |
M. Hamish Bowman, Dept. Marine Science, Otago University, New Zealand<br> |
| 217 |
Functionality inspired by the <em>m.proj</em> and <em>m.proj2</em> modules for |
| 218 |
GRASS GIS 5. |