m.proj.html 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. <p>
  62. Note that 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. <h2>EXAMPLES</h2>
  69. The examples are suitable for the North Carolina sample dataset if not
  70. stated otherwise:
  71. <h3>Reproject vector point coordinate pairs to Long/Lat WGS84</h3>
  72. <p>
  73. The <em>m.proj</em> module is designed to work seamlessly with point
  74. data exported from the GIS
  75. with <em><a href="v.out.ascii.html">v.out.ascii</a></em>, as the
  76. following example shows.
  77. <div class="code"><pre>
  78. # Long/Lat WGS84 output in DMS
  79. v.out.ascii bridges | m.proj -o input=-
  80. # Long/Lat WGS84 output in decimal degree
  81. v.out.ascii bridges | m.proj -o -d input=-
  82. </pre></div>
  83. <h3>Reproject Long/Lat WGS84 coordinate pair to current map projection</h3>
  84. To convert a Long/Lat WGS84 coordinate pair to the current map projection
  85. using the <b>-i</b> flag which sets the target projection parameters
  86. automatically from the current location definition:
  87. <div class="code"><pre>
  88. echo "-78.61168178 33.92225767" | m.proj -i input=-
  89. 645513.47|19180.31|0.00
  90. </pre></div>
  91. <p>
  92. The same, but load points from a file named <tt>waypoints.txt</tt> and
  93. continue on to import the results into a GRASS vector points map in
  94. the current map projection:
  95. <div class="code"><pre>
  96. # check file content
  97. cat waypoints.txt
  98. -78.43977824 33.89587173
  99. -78.54944691 33.88964566
  100. -78.51078074 33.88141495
  101. -77.14037951 35.60543020
  102. # reproject points and generate vector map on the fly
  103. m.proj -i input=waypoints.txt | v.in.ascii input=- output=test_pnts
  104. # verify result
  105. v.db.select test_pnts cat|dbl_1|dbl_2|dbl_3
  106. 1|661427.74|16329.14|0
  107. 2|651285.43|15586.79|0
  108. 3|654867.21|14690.64|0
  109. 4|778074.58|207402.6|0
  110. </pre></div>
  111. <h3>Custom projection parameter usage</h3>
  112. To transform points from a UTM projection (here specified with detailed
  113. projection definition rather than using an EPSG code) into the
  114. Gauss-Kr&uuml;ger Grid System, importing from and exporting to files:
  115. <div class="code"><pre>
  116. m.proj proj_in="+proj=utm +name=utm +a=6378137.0 +es=0.006694380 \
  117. +zone=32 +unfact=1.0" proj_out="+proj=tmerc +name=tmerc \
  118. +a=6377397.155 +es=0.0066743720 +lat_0=0.0 +lon_0=9.0 +k=1.0 \
  119. +x_0=3500000.0" input=utm.coord.txt output=new.gk.coord.txt
  120. </pre></div>
  121. <p>
  122. Projection parameters provided in the above case: <tt>+proj</tt>
  123. (projection type), <tt>+name</tt> (projection name), <tt>+a</tt>
  124. (ellipsoid: equatorial radius), <tt>+es</tt> (ellipsoid:
  125. eccentricity squared), <tt>+zone</tt> (zone for the area),
  126. <tt>+unfact</tt> (conversion factor from meters to other units,
  127. e.g. feet), <tt>+lat_0</tt> (standard parallel), <tt>+lon_0</tt>
  128. (central meridian), <tt>+k</tt> (scale factor) and <tt>+x_0</tt>
  129. (false easting). Sometimes false northing is needed which is coded as
  130. <tt>+y_0</tt>. Internally, the underlying
  131. <a href="http://trac.osgeo.org/proj/">PROJ.4</a> projection library
  132. performs an inverse projection to latitude-longitude and then projects
  133. the coordinate list to the target projection.
  134. <p>
  135. <!-- HB 4/2006: I'm leaving this in from the GRASS 5 help page, but is
  136. it accurate? --> Datum conversions are automatically handled by the
  137. PROJ.4 library if
  138. <tt>+datum</tt> setings are specified on <b>both</b> the input <b>and</b> output
  139. projections on the command line. The <tt>+towgs84</tt> parameter can be used to
  140. define either 3 or 7 term datum transform coefficients, satisfying this requirement.
  141. <p>If a datum is specified there is no need for the <tt>+ellps=</tt> or underlying
  142. parameters, <tt>+a=</tt>, <tt>+es=</tt>, etc.
  143. <p>
  144. Another custom parameter usage example:
  145. <div class="code"><pre>
  146. m.proj proj_in="+proj=tmerc +datum=ire65 +lat_0=53.5 +lon_0=-8 +x_0=200000 \
  147. +y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt
  148. </pre></div>
  149. or without datum transformation:
  150. <div class="code"><pre>
  151. m.proj proj_in="+proj=tmerc +ellps=modif_airy +lat_0=53.5 +lon_0=-8 +x_0=200000 \
  152. +y_0=250000 +k=1.000035" proj_out="+proj=ll +datum=wgs84" input=wpt.txt
  153. </pre></div>
  154. <p>
  155. In this example no datum transformation will take place as a datum was
  156. not specified for the input projection. The datum specified for the
  157. output projection will thus be silently ignored and may be left out;
  158. all that is achieved a simple conversion from projected to geodetic
  159. co-ordinates, keeping the same datum (and thus also the same
  160. ellipsoid).
  161. <p>
  162. For more usage examples, see the documentation for the
  163. <a href="http://trac.osgeo.org/proj/">PROJ.4</a> <em>cs2cs</em> program.
  164. <h2>REFERENCES</h2>
  165. <ul>
  166. <li>Evenden, G.I.
  167. (1990) <a href="ftp://ftp.remotesensing.org/proj/OF90-284.pdf">Cartographic
  168. projection procedures for the UNIX environment - a user's
  169. manual</a>. USGS Open-File Report 90-284 (OF90-284.pdf) See
  170. also there: Interim Report and 2nd Interim Report on Release 4,
  171. Evenden 1994).</li>
  172. <li><a href="http://trac.osgeo.org/proj/">PROJ.4</a> Cartographic Projection Library</li>
  173. </ul>
  174. <h2>SEE ALSO</h2>
  175. <em>
  176. <a href="g.proj.html">g.proj</a>,
  177. <a href="r.proj.html">r.proj</a>,
  178. <a href="v.proj.html">v.proj</a>,
  179. <a href="i.rectify.html">i.rectify</a>,
  180. <a href="v.in.ascii.html">v.in.ascii</a>,
  181. <a href="v.out.ascii.html">v.out.ascii</a>
  182. </em>
  183. <h2>AUTHOR</h2>
  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
  186. GRASS GIS 5.
  187. <p>
  188. <i>Last changed: $Date$</i>