m.proj.html 8.0 KB

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