v.external.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <h2>DESCRIPTION</h2>
  2. <em>v.external</em> creates new vector map as a link to external OGR
  3. layer or PostGIS feature table. OGR (Simple Features Library) is part
  4. of the
  5. <a href="http://www.gdal.org">GDAL</a> library, so you need to install
  6. GDAL to use <em>v.external</em> for external OGR layers. Note that a
  7. PostGIS feature table can be linked also using built-in <em>GRASS-PostGIS
  8. data driver</em> (requires GRASS to be built with PostgreSQL support).
  9. <h2>NOTES</h2>
  10. <p>The simple feature data model used by OGR (or PostGIS) is very
  11. different from the topological format used by GRASS. Instead of true
  12. topology, so called 'pseudo topology' is created for data linked by
  13. <em>v.external</em>. User should learn the difference between those
  14. two formats, because <b>some modules</b> working correctly with GRASS native
  15. data, <b>can produce wrong results</b> with input vector maps created
  16. by <em>v.external</em>.
  17. <p>
  18. <b>Limitations:</b>
  19. <p>
  20. Due to these data model differences <em>v.external</em> does not work
  21. with all data formats. In general, for all formats that do not have a
  22. key column (e.g. SHAPE file), attributes are not accessible, and attributes
  23. would get lost when modifying the geometries. Therefore it is generally
  24. not safe to link vector data with <em>v.external</em>. In many cases it
  25. does not make sense to use <em>v.external</em> linked data with simple
  26. features, instead vector data should be imported with <em>v.import</em>
  27. or <em>v.in.ogr</em> to get true topology support. Importantly, point
  28. cloud data which do not have topology, can be linked with <em>v.external</em>
  29. as long as there are no attributes attached to these point cloud data, or
  30. if the format of the point cloud data has a key column that allows linking
  31. vector geometries to attributes.
  32. <p>See <em><a href="v.db.connect.html">v.db.connect</a></em> for an
  33. example of maintaining attributes in external DBMS in also writable
  34. mode.
  35. <h3>Supported OGR vector formats</h3>
  36. To list supported OGR formats, type
  37. <div class="code"><pre>
  38. v.external -f
  39. </pre></div>
  40. For details see
  41. <a href="https://gdal.org/drivers/vector/">GDAL web site</a>.
  42. <h2>EXAMPLES</h2>
  43. <h3>ESRI Shapefile</h3>
  44. Assuming that 'test_shape.shp' is located in directory
  45. '/home/user/shape_data'.
  46. <div class="code"><pre>
  47. v.external input=/home/user/shape_data layer=test_shape output=grass_map
  48. </pre></div>
  49. <h3>PostGIS layers</h3>
  50. By default, PostGIS links are created by built-in PostGIS support,
  51. ie. using <em>GRASS-PostGIS data driver</em>. If the environment
  52. variable <tt>GRASS_VECTOR_OGR</tt> exists, or GRASS is compiled
  53. without PostgreSQL support then GRASS will use OGR-PostgreSQL driver
  54. for creating a link.
  55. <p>List of layers for given data source can be printed by <b>-l</b>
  56. flag.
  57. <div class="code"><pre>
  58. v.external input="PG:host=localhost user=postgres dbname=postgis" -l
  59. ...
  60. polymap
  61. ...
  62. </pre></div>
  63. <div class="code"><pre>
  64. v.external input="PG:host=localhost user=postgres dbname=postgis" layer=polymap
  65. </pre></div>
  66. Note: Authentication details (user password) can be preferably defined
  67. by <em><a href="db.login.html">db.login</a></em>.
  68. <h3>MapInfo files</h3>
  69. Assuming that 'mapinfo_test' MapInfo file is located in the current
  70. directory (&quot;.&quot;).
  71. <div class="code"><pre>
  72. v.external input=./ layer=mapinfo_test output=grass_map
  73. </pre></div>
  74. <h3>SDTS files</h3>
  75. Note: you have to select the CATD file
  76. <div class="code"><pre>
  77. v.external input=CITXCATD.DDF output=cities
  78. </pre></div>
  79. <h3>TIGER files</h3>
  80. <div class="code"><pre>
  81. v.external input=input/2000/56015/ layer=CompleteChain,PIP output=t56015_all
  82. </pre></div>
  83. <h3>Linking subset of features</h3>
  84. By <b>where</b> option only subset of features can be linked. In the
  85. example below only one feature (in this case a vector tile) will be
  86. linked as a new GRASS vector map.
  87. <div class="code"><pre>
  88. v.external in="PG:dbname=tiles" layer=wrs2_descending where="pr=191026"
  89. ...
  90. Number of areas: 1
  91. ...
  92. </pre></div>
  93. <h2>REFERENCES</h2>
  94. <a href="https://gdal.org/api/">OGR vector library C
  95. API</a> documentation
  96. <h2>SEE ALSO</h2>
  97. <em>
  98. <a href="v.external.out.html">v.external.out</a>,
  99. <a href="v.clean.html">v.clean</a>,
  100. <a href="v.db.connect.html">v.db.connect</a>,
  101. <a href="v.import.html">v.import</a>,
  102. <a href="v.in.db.html">v.in.db</a>,
  103. <a href="v.in.ogr.html">v.in.ogr</a>,
  104. <a href="v.out.ogr.html">v.out.ogr</a>
  105. </em>
  106. <p>
  107. <a href="http://www.gdal.org/">GDAL Library</a>
  108. <br>
  109. <a href="http://postgis.org/">PostGIS</a>
  110. <p>
  111. See
  112. also GRASS <a href="https://grasswiki.osgeo.org/wiki/Working_with_external_data_in_GRASS_7">user wiki page</a> for more examples.
  113. <h2>AUTHORS</h2>
  114. Radim Blazek, ITC-Irst, Trento, Italy
  115. <br>
  116. PostGIS support by Martin Landa, GeoForAll (OSGeoREL) Lab, Czech
  117. Technical University in Prague, Czech Republic
  118. <!--
  119. <p>
  120. <i>Last changed: $Date$</i>
  121. -->