3
This program allows a user to convert coordinates from one projection to
4
another. Coordinates can be read from one file, converted, and results
5
written to another file. Alternatively, if the <b>input</b> and/or
6
<b>output</b> options are omitted, eastings and northings may be passed
7
to the program directly from <tt>stdin</tt> and results sent directly
8
to <tt>stdout</tt>. In this way <em>m.proj</em> can be used as a simple
9
frontend to the <tt><a href="http://proj.maptools.org">PROJ.4</a></tt>
10
<em>cs2cs</em> utility. The <b>-i</b> or <b>-o</b> flags make the task
11
especially easy for the common problem of converting to or from lat/long
14
<i>Note</i>: This program does not transform GRASS maps, it is designed to determine
15
the equivalent coordinate values of an individual position or list of
16
positions. Use <em>v.proj</em> or <em>r.proj</em> to reproject GRASS maps.
21
<em>cs2cs</em> expects input data to formatted as "<tt>x y</tt>", so if working
22
with latitude-longitude data be sure to send the <tt>x</tt> value first,
23
i.e., "<tt>longitude latitude</tt>". Output data will be exported using
26
<em>cs2cs</em> will treat a third data column as a <tt>z</tt> value (elevation)
27
and will modify the value accordingly. This usually translates into small but
28
real differences in that data column.
30
<em>cs2cs</em> does not expect the input stream to contain column headings,
31
only numbers. If your data file has lines you wish to have passed through
32
without being processed, they must start with the '<tt>#</tt>' character.
34
If sending <em>m.proj</em> data from <tt>stdin</tt>, be aware that the data is
35
first stored to a temporary file before being processed with <em>cs2cs</em>.
36
It is therefore not advisable to send <em>m.proj</em> data from an open data
37
stream. The module will stop listening for incoming data after 2 seconds of
38
inactivity. You may use the projection parameters gleaned from <em>m.proj</em>'s
39
verbose mode (<b>-v</b>) with <em>cs2cs</em> directly in this case.
41
Custom projection parameters can be used via the <b>proj_in</b> and
42
<b>proj_out</b> options. Full documentation of the projection parameter
43
format may be found on the <tt><a href="http://proj.maptools.org">PROJ.4</a></tt>
44
website. Using these options will fully override the default parameters the
45
module would normally use.
47
By using the <b>-v</b> verbose flag, the user can see exactly what projection
48
parameters will be used in the conversion as well as some other informative
51
If output is to lat/long, it will be formatted using <tt>PROJ.4</tt>'s
52
Degree:Minute:Second (DMS) convention of <tt>DDDdMM'SSS.SS"H</tt>. This can be handy
53
if you wish to quickly convert lat/long decimal degree data into its DMS
55
Alternatively, to have <em>m.proj</em> output data in decimal degrees, use the
56
<b>-d</b> flag. This flag can also be used with non-lat/long data to force a
57
higher number of decimal places (the <em>cs2cs</em> default is 2).
59
Lat/long output can be converted to GRASS's DMS convention (<tt>DDD:MM:SSS.SSSH</tt>)
60
by piping the results of <em>m.proj</em> through the <em>sed</em> stream
62
<div class="code"><pre>
63
m.proj -o | sed -e 's/d/:/g' -e "s/'/:/g" -e 's/"//g'
66
The <em>m.proj</em> module is designed to work seamlessly with point data
67
exported from the GIS with <em>v.out.ascii</em>, as the following example
69
<div class="code"><pre>
70
v.out.ascii bugsites | m.proj -o
76
To convert a WGS84 long/lat coordinate to the current map projection using
77
the <b>-i</b> flag to set projection parameters automaticlly:
78
<div class="code"><pre>
79
GRASS> echo "170.510125 -45.868537" | m.proj -i
80
2316541.70 5479193.51 1.23
84
The same, but load points from a file named "<tt>waypoints.txt</tt>" and
85
continue on to import the results into a GRASS vector points map in the
86
current map projection:
87
<div class="code"><pre>
88
m.proj -i in=waypoints.txt | cut -f1 -d' ' | v.in.ascii out=test_pt fs=tab
90
Here the standard UNIX <em>cut</em> tool is used to discard the <tt>z</tt>
94
To convert all coordinates from a vector points map in the current projection
95
to WGS84 long/lat, with output in decimal form:
96
<div class="code"><pre>
97
v.out.ascii bugsites | m.proj -od
101
To transform points from a UTM projection into the Gauss-Krüger Grid
102
System, importing and exporting to files:
104
<div class="code"><pre>
105
m.proj <b>proj_in</b>="+proj=utm +name=utm +a=6378137.0 +es=0.006694380 \
106
+zone=32 +unfact=1.0" <b>proj_out</b>="+proj=tmerc +name=tmerc \
107
+a=6377397.155 +es=0.0066743720 +lat_0=0.0 +lon_0=9.0 +k=1.0 \
108
+x_0=3500000.0" <b>input</b>=utm.coord.txt <b>output</b>=new.gk.coord.txt
112
Projection parameters provided in the above case: "<tt>+proj</tt>" (projection
113
type), "<tt>+name</tt>" (projection name), "<tt>+a</tt>" (ellipsoid: equatorial
114
radius), "<tt>+es</tt>" (ellipsoid: eccentricity squared), "<tt>+zone</tt>"
115
(zone for the area), "<tt>+unfact</tt>" (conversion factor from meters to other
116
units, e.g. feet), "<tt>+lat_0</tt>" (standard parallel), "<tt>+lon_0</tt>"
117
(central meridian), "<tt>+k</tt>" (scale factor) and "<tt>+x_0</tt>" (false
118
easting). Sometimes false northing is needed which is coded as "<tt>+y_0</tt>".
119
Internally, the underlying
120
<a href="http://www.remotesensing.org/proj/"><tt>PROJ.4</tt> projection library</a>
121
performs an inverse projection to latitude-longitude and then projects the
122
coordinate list to the target projection.
124
<!-- HB 4/2006: I'm leaving this in from the GRASS 5 help page, but is it accurate? -->
125
Datum conversions are automatically handled by the <tt>PROJ.4</tt> library if
126
"<tt>+datum</tt>" setings are specified on <b>both</b> the input <b>and</b> output
127
projections on the command line. The "<tt>+towgs84</tt>" parameter can be used to
128
define either 3 or 7 term datum transform coefficients, satisfying this requirement.
130
If a datum is specified there is no need for the '<tt>+ellps=</tt>' or underlying
131
parameters, '<tt>+a=</tt>', '<tt>+es=</tt>', etc.
133
<h4>Another custom parameter usage example:</h4>
135
<div class="code"><pre>
136
m.proj <B>proj_in</B>="+proj=tmerc +datum=ire65 +lat_0=53.5 +lon_0=-8 +x_0=200000 \
137
+y_0=250000 +k=1.000035" <B>proj_out</B>="+proj=ll +datum=wgs84" <B>input</B>=wpt.txt
140
or without datum transformation:
142
<div class="code"><pre>
143
m.proj <B>proj_in</B>="+proj=tmerc +ellps=modif_airy +lat_0=53.5 +lon_0=-8 +x_0=200000 \
144
+y_0=250000 +k=1.000035" <B>proj_out</B>="+proj=ll +datum=wgs84" <B>input</B>=wpt.txt
148
In this example no datum transformation will take place as a datum was not
149
specified for the input projection. The datum specified for the output
150
projection will thus be silently ignored and may be left out; all that is
151
achieved a simple conversion from projected to geodetic co-ordinates,
152
keeping the same datum (and thus also the same ellipsoid).</p>
155
For more usage examples, see the documentation for the
156
<tt><a href="http://proj.maptools.org">PROJ.4</a></tt> <em>cs2cs</em> program.
161
[1] Evenden, G.I. (1990) <a href="http://proj.maptools.org/">Cartographic projection procedures for
162
the UNIX environment - a user's manual.</a> USGS Open-File Report 90-284 (OF90-284.pdf)
163
See also there: Interim Report and 2nd Interim Report on Release 4, Evenden 1994).
165
[2] <tt><a href="http://proj.maptools.org">PROJ.4</a></tt> Cartographic Projection Library
171
<A HREF="v.proj.html">v.proj</A>,
172
<A HREF="r.proj.html">r.proj</A>,
173
<A HREF="g.proj.html">g.proj</A>,
174
<A HREF="g.setproj.html">g.setproj</A>,
175
<A HREF="i.rectify.html">i.rectify</A>,
176
<!-- <A HREF="i.rectify3.html">i.rectify3</A> -->
177
<A HREF="v.in.ascii.html">v.in.ascii</A>,
178
<A HREF="v.out.ascii.html">v.out.ascii</A>
184
M. Hamish Bowman, Dept. Marine Science, Otago University, New Zealand<BR>
185
Functionality inspired by the <em>m.proj</em> and <em>m.proj2</em> modules for
188
<p><i>Last changed: $Date: 2006-08-31 10:47:06 +0200 (Thu, 31 Aug 2006) $</i></p>