g.proj.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. <h2>DESCRIPTION</h2>
  2. <p><em>g.proj</em> provides a means of converting a co-ordinate system
  3. description (i.e. projection information) between various formats.
  4. <p>
  5. For an introduction to map projections (with PROJ),see the manual page of
  6. <a href="r.proj.html">r.proj</a>.
  7. <p>
  8. If compiled without <a href="https://gdal.org/">OGR</a> present, the
  9. functionality is limited to:
  10. <ul>
  11. <li>Reporting the projection information for the current location,
  12. either in conventional GRASS (-p flag) or PROJ (-j flag) format</li>
  13. <li>Changing the datum, or reporting and modifying the datum transformation
  14. parameters, for the current location</li>
  15. </ul>
  16. <p>When compiled with OGR, functionality is increased and allows output of
  17. the projection information in the Well-Known Text (WKT) format popularised
  18. by proprietary GIS. In addition, if one of the parameters <em>georef</em>,
  19. <em>wkt</em>, <em>proj4</em> or <em>epsg</em> is specified, rather than the
  20. projection information being read from the current location it is imported
  21. from an external source as follows:
  22. <dl>
  23. <dt>georef=<em>filename</em></dt>
  24. <dd><em>g.proj</em> attempts to invoke GDAL and OGR in turn to read a
  25. georeferenced file <em>filename</em>. The projection information will be
  26. read from this file. If the file is not georeferenced or cannot be read,
  27. XY (unprojected) will be used.</dd>
  28. <dt>wkt=<em>filename</em> or <em>-</em></dt>
  29. <dd>The file <em>filename</em> should contain a projection description in WKT
  30. format with or without line-breaks (e.g. a '.prj' file). If <em>-</em> is given
  31. for the filename, the WKT description will be read from stdin rather than a
  32. file.</dd>
  33. <dt>proj4=<em>description</em> or <em>-</em></dt>
  34. <dd><em>description</em> should be a projection description in
  35. <a href="https://proj.org/">PROJ</a> format, enclosed in
  36. quotation marks if there are any spaces. If <em>-</em> is given for
  37. <em>description</em>, the PROJ description will be read from stdin rather
  38. than as a directly-supplied command-line parameter.</dd>
  39. <dt>epsg=<em>number</em></dt>
  40. <dd><em>number</em> should correspond to the index number of a valid
  41. co-ordinate system in the <a href="http://www.epsg.org/CurrentDB.html">EPSG
  42. database</a>. EPSG code support is based upon a local copy of the GDAL CSV
  43. co-ordinate system and datum information files, stored in the directory
  44. <tt>$GISBASE/etc/proj/ogr_csv</tt>. These can be updated if necessary
  45. to support future revisions of the EPSG database.</dd>
  46. </dl>
  47. <p>If datum information is incorrect or missing in the input
  48. co-ordinate system definition (e.g. PROJ descriptions have very limited
  49. support for specifying datum names), a GRASS datum abbreviation can instead be
  50. supplied using the <em>datum</em> parameter. This will override any
  51. datum contained in the input co-ordinate system, and discard
  52. any datum transformation parameters. Enter datum=<em>list</em> to return a
  53. list of all the datums supported by GRASS. Since any
  54. existing datum transformation parameters will have been discarded, the
  55. <em>datumtrans</em> parameter should in general always be used in
  56. conjunction with <em>datum</em>.
  57. <p>The -p, -j, -w, etc. flags are all functional when importing projection
  58. information from an external source, meaning that <em>g.proj</em> can be
  59. used to convert between representations of the information. It is
  60. <strong>not</strong> required that either the input or output be in GRASS
  61. format.
  62. <p>In addition however, if the -c flag is specified, <em>g.proj</em> will
  63. create new GRASS projection files (PROJ_INFO, PROJ_UNITS, WIND and
  64. DEFAULT_WIND) based on the imported information. If the <em>location</em>
  65. parameter is specified in addition to -c, then a new location will be created.
  66. Otherwise the projection information files in the current location will be
  67. overwritten. The program will <strong>not</strong> warn before doing this.
  68. <p>The final mode of operation of g.proj is to report on the datum
  69. information and datum transformation parameters associated with the
  70. co-ordinate system. The -d flag will report a human-readable summary of
  71. this.
  72. <h2>NOTES</h2>
  73. <p>If the input co-ordinate system contains a datum name but no
  74. transformation parameters, and there is more than one suitable parameter set
  75. available (according to the files datum.table and datumtransform.table in
  76. <tt>$GISBASE/etc/proj</tt>), <em>g.proj</em> will check the value of
  77. the <em>datumtrans</em> option and act according to the following:<br>
  78. <strong>-1:</strong> List available parameter sets in a GUI-parsable (but also
  79. human-readable) format and exit.<br>
  80. <strong>0 (default):</strong> Continue without specifying parameters - if
  81. used when creating a location, other GRASS modules will use the "default"
  82. (likely non-optimum) parameters for this datum if necessary in the future.<br>
  83. <strong>Any other number less than or equal to the number of parameter sets
  84. available for this datum:</strong> Choose this parameter set and add it to the
  85. co-ordinate system description.<br>
  86. If the <em>-t</em> flag is specified, the module will attempt to change the
  87. datum transformation parameters using one of the above two methods
  88. <strong>even if</strong> a valid parameter set is already specified in the
  89. input co-ordinate system. This can be useful to change the datum information
  90. for an existing location.
  91. <p>Output is simply based on the input projection information. g.proj does
  92. <strong>not</strong> attempt to verify that the co-ordinate system thus
  93. described matches an existing system in use in the world. In particular,
  94. this means there are no EPSG Authority codes in the WKT output.
  95. <p>WKT format shows the false eastings and northings in the projected unit
  96. (e.g. meters, feet) but in PROJ format it should always be given in meters.
  97. <p>The maximum size of input WKT or PROJ projection descriptions is
  98. limited to 8000 bytes.
  99. <h2>EXAMPLES</h2>
  100. <h3>Print information</h3>
  101. Print the projection information for the current location:<br>
  102. <div class="code"><pre>
  103. g.proj -p
  104. </pre></div>
  105. <p>
  106. List the possible datum transformation parameters for the current location:<br>
  107. <div class="code"><pre>
  108. g.proj -t datumtrans=-1
  109. </pre></div>
  110. <h3>Create projection (PRJ) file</h3>
  111. Create a '.prj' file in ESRI format corresponding to the current location:<br>
  112. <div class="code"><pre>
  113. g.proj -wef > irish_grid.prj
  114. </pre></div>
  115. <h3>Read projection from file</h3>
  116. Read the projection information from a GeoTIFF file and print it in PROJ
  117. format:<br>
  118. <div class="code"><pre>
  119. g.proj -jf georef=ASTER_DEM20020508161837.tif
  120. </pre></div>
  121. <p>Convert the PROJ projection description contained in a text file to WKT
  122. format:<br>
  123. <div class="code"><pre>
  124. cat proj4.description | g.proj -w proj4=-
  125. </pre></div>
  126. <h3>Create new location</h3>
  127. <p>Create a new location with the co-ordinate system referred to by EPSG code
  128. 4326 (Latitude-Longitude/WGS84), without explicitly specifying datum
  129. transformation parameters:<br>
  130. <div class="code"><pre>
  131. g.proj -c epsg=4326 location=latlong
  132. </pre></div>
  133. <p>Create a new location with the co-ordinate system referred to by ESRI-EPSG code
  134. 900913 (<a href="http://spatialreference.org/ref/user/6/">Google Mercator Projection</a>)<br>
  135. <div class="code"><pre>
  136. g.proj -c epsg=900913 location=google
  137. </pre></div>
  138. <p>Create a new location with the co-ordinate system referred to by EPSG code
  139. 29900 (Irish Grid), selecting datum transformation parameter set no. 2:<br>
  140. <div class="code"><pre>
  141. # list available datums for EPSG code 29900
  142. g.proj -t datumtrans=-1 epsg=29900
  143. g.proj -c epsg=29900 datumtrans=2 location=irish_grid
  144. </pre></div>
  145. <p>Create a new location with the same co-ordinate system as the current
  146. location, but forcing a change to datum transformation parameter set no. 1:<br>
  147. <div class="code"><pre>
  148. g.proj -c location=newloc -t datumtrans=1
  149. </pre></div>
  150. <p>Create a new location with the co-ordinate system from a WKT definition
  151. stored in a text file:<br>
  152. <div class="code"><pre>
  153. g.proj -c wkt=irish_grid.prj location=irish_grid
  154. </pre></div>
  155. <p>Create a new location from a PROJ description, explicitly
  156. specifying a datum and using the default datum transformation
  157. parameters:<br>
  158. <div class="code"><pre>
  159. g.proj -c location=spain proj4="+proj=utm +zone=30 +ellps=intl" datum=eur50 datumtrans=0
  160. </pre></div>
  161. <h3>Using g.proj output for GDAL/OGR tools</h3>
  162. <p>Reproject external raster map to current GRASS projection (does not always make sense!)
  163. using the GDAL 'gdalwarp' tool. We recommend to use the ERDAS/Img format and not
  164. to use the ESRI style of WKT:<br>
  165. <div class="code"><pre>
  166. # example for 30x30 pixel resolution (enforce with -tr to avoid odd values)
  167. gdalwarp -of HFA -tr 30 30 -t_srs "`g.proj -wf`" aster.img aster_tmerc.img
  168. </pre></div>
  169. <p>Reproject external vector map to current GRASS projection
  170. using the OGR 'ogr2ogr' tool:<br>
  171. <div class="code"><pre>
  172. ogr2ogr -t_srs "`g.proj -wf`" polbnda_italy_GB_ovest.shp polbnda_italy_LL.shp
  173. </pre></div>
  174. <h2>REFERENCES</h2>
  175. <a href="https://proj.org">PROJ</a>: Projection/datum support library<br>
  176. <a href="https://gdal.org">GDAL raster library and toolset</a><br>
  177. <a href="https://gdal.org/">OGR vector library and toolset</a>
  178. <p><b>Further reading</b>
  179. <ul>
  180. <li> <a href="https://www.asprs.org/asprs-publications/grids-and-datums">ASPRS Grids and Datum</a>
  181. <li> <a href="http://www.mapref.org">MapRef - The Collection of Map Projections and Reference Systems for Europe</a>
  182. <li> <a href="http://geotiff.maptools.org/proj_list/">Projections Transform List</a> (PROJ)
  183. </ul>
  184. <h2>SEE ALSO</h2>
  185. <em>
  186. <a href="m.proj.html">m.proj</a>,
  187. <a href="r.proj.html">r.proj</a>,
  188. <a href="v.proj.html">v.proj</a>,
  189. <a href="r.import.html">r.import</a>,
  190. <a href="r.in.gdal.html">r.in.gdal</a>,
  191. <a href="v.import.html">v.import</a>,
  192. <a href="v.in.ogr.html">v.in.ogr</a>
  193. </em>
  194. <h2>AUTHOR</h2>
  195. Paul Kelly