m.proj.html 8.0 KB

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