vectorintro.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <!-- meta page description: Vector data processing in GRASS GIS -->
  2. <!-- meta page index: vector -->
  3. <h3>Vector maps in general</h3>
  4. A "vector map" is a data layer consisting of a number of sparse features
  5. in geographic space. These might be data points (drill sites), lines
  6. (roads), polygons (park boundary), volumes (3D CAD structure), or some
  7. combination of all these. Typically each feature in the map will be
  8. tied to a set of attribute layers stored in a database (road names,
  9. site ID, geologic type, etc.). As a general rule these can exist in 2D
  10. or 3D space and are independent of the GIS's computation region.
  11. <h3>Attribute management</h3>
  12. The default database driver used by GRASS GIS 7 is SQLite. GRASS GIS
  13. handles multiattribute vector data by default. The <em>db.*</em> set of
  14. commands provides basic SQL support for attribute management, while the
  15. <em>v.db.*</em> set of commands operates on vector maps.
  16. <p>
  17. Note: The list of available database drivers can vary in various binary
  18. distributions of GRASS GIS, for details see
  19. <a href="sql.html">SQL support in GRASS GIS</a>.
  20. <h3>Vector data import and export</h3>
  21. The <a href="v.in.ogr.html">v.in.ogr</a> module offers a common
  22. interface for many different vector formats. Additionally, it
  23. offers options such as on-the-fly creation of new locations or extension of
  24. the default region to match the extent of the imported vector map.
  25. For special cases, other import modules are available, e.g.
  26. <a href="v.in.ascii.html">v.in.ascii</a> for input from a text file
  27. containing coordinate and attribute data, and
  28. <a href="v.in.db.html">v.in.db</a> for input from a database containing
  29. coordinate and attribute data.
  30. With <a href="v.external.html">v.external</a> external maps can be
  31. virtually linked into a mapset, only pseudo-topology is generated but
  32. the vector geometry is not imported.
  33. The <em>v.out.*</em> set of commands exports to various formats. To import
  34. and export only attribute tables, use <a href="db.in.ogr.html">db.in.ogr</a>
  35. and <a href="db.out.ogr.html">db.out.ogr</a>.
  36. <p>
  37. GRASS GIS vector map exchange between different locations (same projection)
  38. can be done in a lossless way using the <a href="v.pack.html">v.pack</a>
  39. and <a href="v.unpack.html">v.unpack</a> modules.
  40. <p>
  41. The naming convention for vector maps requires that map names start with a
  42. character, not a number (map name scheme: [A-Za-z][A-Za-z0-9_]*).
  43. <h3>Metadata</h3>
  44. The <a href="v.info.html">v.info</a> display general information such
  45. as metadata and attribute columns about a vector map including the
  46. history how it was generated. Each map generating command stores the
  47. command history into the metadata (query with <a href="v.info.html">v.info -h mapname</a>).
  48. Metadata such as map title, scale, organization etc. can be updated
  49. with <a href="v.support.html">v.support</a>.
  50. <h3>Vector map operations</h3>
  51. GRASS vector map processing is always performed on the full map.
  52. If this is not desired, the input map has to be clipped to the
  53. current region beforehand (<a href="v.in.region.html">v.in.region</a>,
  54. <a href="v.overlay.html">v.overlay</a>, <a href="v.select.html">v.select</a>).
  55. <h3>Vector model and topology</h3>
  56. GRASS is a topological GIS. This means that adjacent geographic
  57. components in a single vector map are related. For example in a
  58. non-topological GIS if two areas shared a common border that border
  59. would be digitized two times and also stored in duplicate. In a
  60. topological GIS this border exists once and is shared between two
  61. areas. Topological representation of vector data helps to produce and
  62. maintain vector maps with clean geometry as well as enables certain
  63. analyses that can not be conducted with non-topological or spaghetti
  64. data. In GRASS, topological data are referred to as level 2 data and
  65. spaghetti data is referred to as level 1.
  66. <p>
  67. Sometimes topology is not necessary and the additional memory and
  68. space requirements are burdensome to a particular task. Therefore two
  69. modules allow for working level 1 (non-topological) data within
  70. GRASS. The <a href="v.in.ascii.html">v.in.ascii</a> module allows
  71. users to input points without building topology. This is very useful
  72. for large files where memory restrictions may cause difficulties. The
  73. other module which works with level 1 data is
  74. <a href="v.surf.rst.html">v.surf.rst</a> which enables spatial
  75. approximation and topographic analysis from a point or isoline file.
  76. <p> In GRASS, the following vector object types are defined:
  77. <ul>
  78. <li> point: a point; </li>
  79. <li> line: a directed sequence of connected vertices with two endpoints called nodes; </li>
  80. <li> boundary: the border line to describe an area; </li>
  81. <li> centroid: a point within a closed ring of boundaries; </li>
  82. <li> area: the topological composition of a closed ring of boundaries and a centroid; </li>
  83. <li> face: a 3D area; </li>
  84. <li> kernel: a 3D centroid in a volume (not yet implemented); </li>
  85. <li> volume: a 3D corpus, the topological composition of faces and kernel (not yet implemented). </li>
  86. </ul>
  87. <p>
  88. Lines and boundaries can be composed of multiple vertices.
  89. <p>
  90. Area topology also holds information about isles. These isles are located
  91. within that area, not touching the boundaries of the outer area. Isles
  92. are holes inside the area, and can consist of one or more areas. They are used
  93. internally to maintain correct topology for areas.
  94. <p>
  95. The <a href="v.type.html">v.type</a> module can be used to convert
  96. between vector types if
  97. possible. The <a href="v.build.html">v.build</a> module is used to
  98. generate topology. It optionally allows the user to extract erroneous
  99. vector objects into a separate map. Topological errors can be
  100. corrected either manually
  101. within <a href="wxGUI.vdigit.html">wxGUI vector digitizer</a> or,
  102. to some extent, automatically in <a href="v.clean.html">v.clean</a>.
  103. A dedicated vector editing module is <a href="v.edit.html">v.edit</a>
  104. which supports global and local editing operations.
  105. Adjacent polygons can be found by <a href="v.to.db.html">v.to.db</a>
  106. (see 'sides' option).
  107. <p>
  108. Many operations including extraction, queries, overlay, and export will
  109. only act on features which have been assigned a category number. Typically
  110. a centroid will hold the attribute data for the area with which the centroid is
  111. associated. Boundaries are not typically given a category ID as it would be
  112. ambiguous as to which area either side of it the attribute data would belong
  113. to. An exception might be when the boundary between two crop-fields is the
  114. center-line of a road, and the category information is an index to the road
  115. name. For everyday use boundaries and centroids can be treated as internal
  116. data types and the user can work directly and more simply with the "area"
  117. type.
  118. <h3>Vector object categories and attribute management</h3>
  119. GRASS vectors can be linked to one or many database management systems
  120. (DBMS). The <em>db.*</em> set of commands provides basic SQL support for
  121. attribute management, while the <em>v.db.*</em> set of commands operates
  122. on a table linked to a vector map.
  123. <ul>
  124. <li><b>Categories</b><br>
  125. Categories are used to categorize vector objects and link
  126. attribute(s) to each category. Each vector object can have zero, one or
  127. several categories. Category numbers do not have to be unique for
  128. each vector object, several vector objects can share the same category.
  129. <br>Category numbers are stored both within the geometry file for each
  130. vector object and within the (optional) attribute table(s) (usually the "cat"
  131. column). It is not required that attribute table(s) hold an entry for
  132. each category, and attribute table(s) can hold
  133. information about categories not present in the vector geometry file.
  134. This means that e.g. an attribute table can be populated first and then
  135. vector objects can be added to the geometry file with category numbers.
  136. Using <a href="v.category.html">v.category</a>, category numbers can be
  137. printed or maintained.
  138. <br><br></li>
  139. <li><b>Layers</b><br>
  140. Layers are a characteristic of the vector feature (geometries) file.
  141. As mentioned above, categories allow the user to give either a
  142. unique id to each feature or to group similar features by giving
  143. them all the same id. Layers allow several parallel, but different
  144. groupings of features in a same map. The practical benefit of this
  145. system is that it allows placement of thematically distinct but
  146. topologically related objects into a single map, or for linking time
  147. series attribute data to a series of locations that did not change
  148. over time.
  149. <br>
  150. For example, one can have roads with one layer
  151. containing the unique id of each road and another layer with ids for
  152. specific routes that one might take, combining several roads by
  153. assigning the same id. While this example can also be dealt with in
  154. an attribute table, another example of the use of layers that shows
  155. their specific advantage is the possibility to identify the same geometrical
  156. features as representing different thematic objects. For example,
  157. in a map with a series of polygons representing fields in
  158. which at the same time the boundaries of these fields have a meaning
  159. as linear features, e.g. as paths, one can give a unique id to each
  160. field as area in layer 1, and a unique id in layer 2 to those
  161. boundary lines that are paths. If the paths will always depend on
  162. the field boundaries (and might change if these boundaries
  163. change) then keeping them in the same map can be helpful. Trying
  164. to reproduce the same functionality through attributes is much more
  165. complicated.
  166. <br>
  167. If a vector object has zero categories in a layer, then it does not
  168. appear in that layer. In this fashion some vector objects may appear
  169. in some layers but not in others. Taking the example of the fields
  170. and paths, only some boundaries, but not all, might have a category
  171. value in layer 2. With <em>option=report</em>,
  172. <a href="v.category.html">v.category</a> lists available categories
  173. in each layer.
  174. <br>
  175. Optionally, each layer can (but does not have
  176. to) be linked to an attribute table. The link is made by the
  177. category values of the features in that layer which have to have
  178. corresponding entries in the specified key column of the table.
  179. Using <a href="v.db.connect.html">v.db.connect</a> connections
  180. between layers and attribute tables can be listed or maintained.
  181. <br>
  182. In most modules, the first layer (<em>layer=1</em>) is active by
  183. default. Using <em>layer=-1</em> one can access all layers.
  184. </li>
  185. <li><b>SQL support</b><br>
  186. By default, SQLite is used as the attribute database. Also other
  187. supported DBMS backends (such as SQLite, PostgreSQL, MySQL etc.)
  188. provide full SQL support as the SQL statements are sent directly
  189. to GRASS' database management interface (DBMI). Only the DBF driver
  190. provides just very limited SQL support (as DBF is not an SQL DB).
  191. SQL commands can be directly executed with
  192. <a href="db.execute.html">db.execute</a>,
  193. <a href="db.select.html">db.select</a> and the other db.* modules.
  194. </li>
  195. </ul>
  196. When creating vector maps from scratch, in general an attribute table must be created and
  197. the table must be populated with one row per category (using <a href="v.to.db.html">v.to.db</a>).
  198. However, this can be performed in a single step using <a href="v.db.addtable.html">v.db.addtable</a>
  199. along with the definition of table column types. Column adding and dropping
  200. can be done with <a href="v.db.addcolumn.html">v.db.addcolumn</a> and
  201. <a href="v.db.dropcolumn.html">v.db.dropcolumn</a>. A table column can be renamed with
  202. <a href="v.db.renamecolumn.html">v.db.renamecolumn</a>. To drop a table from a map, use
  203. <a href="v.db.droptable.html">v.db.droptable</a>. Values in a table can be updated
  204. with <a href="v.db.update.html">v.db.update</a>. Tables can be joined with with
  205. <a href="v.db.join.html">v.db.join</a>.
  206. <h3>Editing vector attributes</h3>
  207. To manually edit attributes of a table, the map has to be
  208. queried in 'edit mode' using <a href="d.what.vect.html">d.what.vect</a>.
  209. To bulk process attributes, it is recommended to use SQL
  210. (<a href="db.execute.html">db.execute</a>).
  211. <h3>Geometry operations</h3>
  212. The module <a href="v.in.region.html">v.in.region</a> saves the
  213. current region extents as a vector area.
  214. Split vector lines can be converted to polylines by
  215. <a href="v.build.polylines.html">v.build.polylines</a>. Long lines can be
  216. split by <a href="v.split.html">v.split</a> and
  217. <a href="v.segment.html">v.segment</a>.
  218. Buffer and circles can be generated with <a href="v.buffer.html">v.buffer</a>
  219. and <a href="v.parallel.html">v.parallel</a>.
  220. <a href="v.generalize.html">v.generalize</a> is module for generalization of GRASS vector maps.
  221. 2D vector maps can be changed to 3D using
  222. <a href="v.drape.html">v.drape</a> or <a href="v.extrude.html">v.extrude</a>.
  223. If needed, the spatial position of vector points can be perturbed by
  224. <a href="v.perturb.html">v.perturb</a>.
  225. The <a href="v.type.html">v.type</a> command changes between vector
  226. types (see list above).
  227. Projected vector maps can be reprojected with <a href="v.proj.html">v.proj</a>.
  228. Unprojected maps can be geocoded with <a href="v.transform.html">v.transform</a>.
  229. Based on the control points, <a href="v.rectify.html">v.rectify</a> rectifies a
  230. vector map by computing a coordinate transformation for each vector object.
  231. Triangulation and point-to-polygon conversions can be done with <a
  232. href="v.delaunay.html">v.delaunay</a>, <a href="v.hull.html">v.hull</a>,
  233. and <a href="v.voronoi.html">v.voronoi</a>.
  234. The <a href="v.random.html">v.random</a> command generated random points.
  235. <h3>Vector overlays and selections</h3>
  236. Geometric overlay of vector maps is done with <a href="v.patch.html">v.patch</a>,
  237. <a href="v.overlay.html">v.overlay</a> and <a href="v.select.html">v.select</a>,
  238. depending on the combination of vector types.
  239. Vectors can be extracted with <a href="v.extract.html">v.extract</a>
  240. and reclassified with <a href="v.reclass.html">v.reclass</a>.
  241. <h3>Vector statistics</h3>
  242. Statistics can be generated by <a href="v.qcount.html">v.qcount</a>,
  243. <a href="v.sample.html">v.sample</a>, <a href="v.normal.html">v.normal</a>,
  244. <a href="v.univar.html">v.univar</a>, and <a href="v.vect.stats.html">v.vect.stats</a>.
  245. Distances between vector objects are calculated with <a href="v.distance.html">v.distance</a>.
  246. <h3>Vector-Raster-DB conversion</h3>
  247. The <a href="v.to.db.html">v.to.db</a> transfers vector information
  248. into database tables.
  249. With <a href="v.to.points.html">v.to.points</a>,
  250. <a href="v.to.rast.html">v.to.rast</a> and <a href="v.to.rast3.html">v.to.rast3</a>
  251. conversions are performed. Note that a raster mask ("MASK") will not be
  252. respected since it is only applied when <em>reading</em> an existing
  253. GRASS raster map.
  254. <h3>Vector queries</h3>
  255. Vector maps can be queried with <a href="v.what.html">v.what</a> and
  256. <a href="v.what.vect.html">v.what.vect</a>.
  257. <h3>Vector-Raster queries</h3>
  258. Raster values can be transferred to vector maps with
  259. <a href="v.what.rast.html">v.what.rast</a> and
  260. <a href="v.rast.stats">v.rast.stats</a>.
  261. <h3>Vector network analysis</h3>
  262. GRASS provides support for vector network analysis. The following algorithms
  263. are implemented:
  264. <ul>
  265. <li> Network preparation and maintenance: <a href="v.net.html">v.net</a></li>
  266. <li> Shortest path: <a href="d.path.html">d.path</a> and
  267. <a href="v.net.path.html">v.net.path</a></li>
  268. <li> Shortest path between all pairs of nodes <a href="v.net.allpairs.html">v.net.allpairs</a>
  269. <li> Allocation of sources (create subnetworks, e.g. police station zones):
  270. <a href="v.net.alloc.html">v.net.alloc</a></li>
  271. <li> Iso-distances (from centers): <a href="v.net.iso.html">v.net.iso</a></li>
  272. <li> Computes bridges and articulation points: <a href="v.net.bridge.html">v.net.bridge</a></li>
  273. <li> Computes degree, centrality, betweeness, closeness and eigenvector centrality measures: <a href="v.net.centrality.html">v.net.centrality</a></li>
  274. <li> Computes strongly and weakly connected components: <a href="v.net.components.html">v.net.components</a></li>
  275. <li> Computes vertex connectivity between two sets of nodes: <a href="v.net.connectivity.html">v.net.connectivity</a></li>
  276. <li> Computes shortest distance via the network between the given sets of features: <a href="v.net.distance.html">v.net.distance</a></li>
  277. <li> Computes the maximum flow between two sets of nodes: <a href="v.net.flow.html">v.net.flow</a></li>
  278. <li> Computes minimum spanning tree:<a href="v.net.spanningtree.html">v.net.spanningtree</a></li>
  279. <li> Minimum Steiner trees (star-like connections, e.g. broadband cable
  280. connections): <a href="v.net.steiner.html">v.net.steiner</a></li>
  281. <li> Finds shortest path using timetables: <a href="v.net.timetable.html">v.net.timetable</a></li>
  282. <li> Traveling salesman (round trip): <a href="v.net.salesman.html">v.net.salesman</a></li>
  283. </ul>
  284. Vector directions are defined by the digitizing direction (a--&gt;--b).
  285. Both directions are supported, most network modules provide parameters
  286. to assign attribute columns to the forward and backward direction.
  287. <h3>Vector networks: Linear referencing system (LRS)</h3>
  288. LRS uses linear features and distance measured along those features to
  289. positionate objects. There are the commands
  290. <a href="v.lrs.create.html">v.lrs.create</a> to create a linear reference system,
  291. <a href="v.lrs.label.html">v.lrs.label</a> to create stationing on the LRS,
  292. <a href="v.lrs.segment.html">v.lrs.segment</a> to create points/segments on LRS,
  293. and
  294. <a href="v.lrs.where.html">v.lrs.where</a> to find line id and real km+offset
  295. for given points in vector map using linear reference system.
  296. <p>
  297. The <a href="lrs.html">LRS tutorial</a> explains further details.
  298. <h3>Interpolation and approximation</h3>
  299. Some of the vector modules deal with spatial or volumetric
  300. approximation (also called interpolation):
  301. <a href="v.kernel.html">v.kernel</a>,
  302. <a href="v.surf.idw.html">v.surf.idw</a>,
  303. <a href="v.surf.rst.html">v.surf.rst</a>, and
  304. <a href="v.vol.rst.html">v.vol.rst</a>.
  305. <h3>Lidar data processing</h3>
  306. Lidar point clouds (first and last return) are imported from text files
  307. with <a href="v.in.ascii.html">v.in.ascii</a> or from LAS files with
  308. <a href="v.in.lidar.html"> v.in.lidar</a>. Both modules recognize the
  309. -b flag to not build topology. Outlier detection is done with
  310. <a href="v.outlier.html">v.outlier</a> on both first and last return data.
  311. Then, with <a href="v.lidar.edgedetection.html">v.lidar.edgedetection</a>,
  312. edges are detected from last return data. The building are generated by
  313. <a href="v.lidar.growing.html">v.lidar.growing</a> from detected
  314. edges. The resulting data are post-processed with
  315. <a href="v.lidar.correction.html">v.lidar.correction</a>. Finally, the
  316. DTM and DSM are generated with <a href="v.surf.bspline.html">v.surf.bspline</a>
  317. (DTM: uses the 'v.lidar.correction' output; DSM: uses last return output
  318. from outlier detection).<br>
  319. In addition, <a href="v.decimate.html">v.decimate</a> can be used to decimates
  320. a point cloud.
  321. <h3>See also</h3>
  322. <ul>
  323. <li><a href="rasterintro.html">Introduction to raster data processing</a></li>
  324. <li><a href="raster3dintro.html">Introduction to 3D raster data (voxel) processing</a></li>
  325. <li><a href="imageryintro.html">Introduction to image processing</a></li>
  326. <li><a href="temporalintro.html">Introduction into temporal data processing</a></li>
  327. <li><a href="databaseintro.html">Introduction to database management</a></li>
  328. <li><a href="projectionintro.html">Projections and spatial transformations</a></li>
  329. </ul>