grasslib.dox 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. /*! \mainpage GRASS GIS 7 Programmer's Manual
  2. <!-- * doxygenized from "GRASS 5 Programmer's Manual"
  3. by M. Neteler 2/2004
  4. * updated 8/2005, 2006-2008, 2010-2011
  5. -->
  6. <a href="http://grass.osgeo.org">GRASS GIS</a> (<b>Geographic
  7. Resources Analysis Support System</b>) is an open source, free
  8. software <em>Geographical Information System</em> (GIS) with raster,
  9. topological %vector, image processing, and graphics production
  10. functionality that operates on various platforms through a graphical
  11. user interface (GUI) or command line interface (CLI). It is released
  12. under <a href="http://www.fsf.org/copyleft/gpl.html">GNU General
  13. Public License</a> (GPL).
  14. This manual introduces the reader to the <i>Geographic Resources
  15. Analysis Support System</i> from the programming perspective. Design
  16. theory, system support libraries, system maintenance, and system
  17. enhancement are all presented. This work is part of ongoing research
  18. being performed by the <a
  19. href="http://grasswiki.osgeo.org/wiki/Team">GRASS Development
  20. Team</a>, an international team of programmers, GRASS module authors
  21. are cited within their module's source code and the contributed manual
  22. pages.
  23. &copy; 2000-2014 by the GRASS Development Team
  24. This manual is published under <a
  25. href="http://www.fsf.org/copyleft/fdl.html">GNU Free Documentation
  26. License</a> (GFDL), and comes with ABSOLUTELY NO WARRANTY. The
  27. development of GRASS software and this manual is kindly supported by
  28. the <a href="http://www.osgeo.org">Open Source Geospatial
  29. Foundation</a>, who provides the GRASS main infrastructure.
  30. Main web site: <a
  31. href="http://grass.osgeo.org">http://grass.osgeo.org</a>
  32. <i>Note: Missing entries below still need to be documented in Doxygen format.</i>
  33. <!-- original:
  34. http://trac.osgeo.org/grass/browser/grass-web/trunk/images/grass7_arch.odp
  35. -->
  36. \image html "grass7_arch.png" "GRASS 7 Architecture"
  37. \section libsOverview Libraries
  38. \section corelibs Core libraries
  39. (the name refers to the directory name in <tt>lib/</tt> in the source code)
  40. - gis: \ref gislib
  41. - raster: \ref rasterlib
  42. - vector: \ref vectorlib
  43. - Temporal GIS API: See http://grass.osgeo.org/grass71/manuals/libpython/temporal_framework.html
  44. \section interfaces Interfaces
  45. - Python script interface: \ref pythonlib
  46. - %PyGRASS: A Python based object oriented raster, vector library interface
  47. \section libs Further libraries
  48. (the name refers to the directory name in <tt>lib/</tt> in the source code)
  49. \subsection displaylibs Display Libraries and Drivers
  50. - display: \ref displaylib (general displaylibrary)
  51. - cairodriver: \ref cairodriver (cairo graphics driver)
  52. - %driver: Graphics monitor driver
  53. - htmldriver: \ref htmldriverlib (HTML graphics driver)
  54. - pngdriver: \ref pngdriverlib (PNG graphics driver)
  55. - psdriver: \ref psdriverlib (Postscript graphics driver)
  56. \subsection statslibs Math and Statisctics Libraries
  57. - arraystats: \ref arraystatslib (library of statistics for arrays of doubles)
  58. - cdhc: \ref cdhclib (library for testing normality and exponentiality)
  59. - gmath: \ref gmathlib (generic mathematical functions and BLAS/LAPACK library wrapper)
  60. - gpde: \ref gpdelib (partial differential equations library)
  61. \subsection rasteribs Raster Libraries
  62. - raster: \ref rasterlib (2D raster library)
  63. - raster3d: \ref raster3dlib (3D raster library - voxels)
  64. - rowio: \ref rowiolib (library for reading/writing raster rows)
  65. - rst: \ref rstlib (library for interpolation with regularized splines with tension)
  66. - segment: \ref segmentlib (segment library for segmented raster reading)
  67. - stats: \ref statslib (statistics library)
  68. \subsection imagerylibs Imagery Libraries (image processing)
  69. - cluster: \ref clusterlib (library for k-means style of cluster analysis processing)
  70. - imagery: \ref imagerylib (library for image processing)
  71. \subsection vectoribs Vector Libraries
  72. - %vector: \ref vectorlib (architecture description)
  73. - dglib: \ref dglib (directed graph library)
  74. - vedit: \ref veditlib (vector editing library)
  75. - neta: \ref netalib (network analysis library)
  76. - rtree: \ref rtree (R search tree library)
  77. \subsection dblibs Database Management Libraries
  78. - db: \ref dbmilib
  79. \subsection ogsflibs OpenGL Libraries and friends
  80. - ogsf: \ref ogsflib (OpenGL (R) ported gsurf library (required for NVIZ))
  81. - nviz: \ref nvizlib (used by wxGUI Nviz extension and CLI-based Nviz module)
  82. \subsection pythonlibs Python API
  83. - python: See GRASS GIS Python library (http://grass.osgeo.org/grass71/manuals/libpython/)
  84. \subsection projlibs Projection Libraries
  85. - proj: \ref projlib (wrapper to PROJ4 projection library)
  86. \subsection misclibs Misc Libraries
  87. - datetime: \ref datetime (DateTime library)
  88. - external: \ref external (External libraries from other projects such as shapelib)
  89. - fonts: \ref fonts (GRASS fonts library)
  90. - init: \ref init (GRASS initialization code + scripts)
  91. - iostream: \ref iostream (fast I/O library)
  92. - lidar: \ref lidar (LiDAR data related library)
  93. - linkm: \ref linkm (linked list memory manager)
  94. - manage: \ref managelib
  95. - symbol: \ref symbol (Drawing symbols for %point %vector data library)
  96. \section gui GUI
  97. - \ref wxpythonlib
  98. \section location File structure of GRASS Location
  99. A GRASS <b>raster map</b> consists of several files in several subdirectories in a mapset,
  100. organized as follows:
  101. <dl>
  102. <dt><b>cellhd/</b></dt>
  103. <dd>map header including projection code, coordinates representing
  104. the spatial extent of the raster map, number of rows and columns, resolution,
  105. and information about map compression;</dd>
  106. <dt><b>cell/, fcell/ or grid3/</b></dt>
  107. <dd>generic matrix of values in a compressed, portable
  108. format which depends on the raster data type (integer, floating %point or 3D grid);</dd>
  109. <dt><b>hist/</b></dt>
  110. <dd>history file which contains metadata such as the data source,
  111. the command that was used to generate the raster map, or
  112. other information provided by the user;</dd>
  113. <dt><b>cats/</b></dt>
  114. <dd>optional category file which contains text or numeric labels assigned
  115. to the raster map categories;</dd>
  116. <dt><b>colr/</b></dt>
  117. <dd>optional color table;</dd>
  118. <dt><b>cell_misc/</b></dt>
  119. <dd>optional timestamp, range of values, quantization rules (for floating %point maps)
  120. and null (no-data) files;</dd>
  121. </dl>
  122. A GRASS <b>%vector maps</b> are stored in several separate files in a
  123. single directory (see \ref vectorlib). While the
  124. attributes are stored in either a DBF file, a SQLite file or in an
  125. external DBMS (PostgreSQL, MySQL, ODBC), the geometric data are saved
  126. as follows:
  127. <dl>
  128. <dt><b>head</b></dt>
  129. <dd>%vector map ASCII header with information about the map creation
  130. (date and name), its scale and threshold;</dd>
  131. <dt><b>coor</b></dt>
  132. <dd>binary geometry file which includes the coordinates of graphic
  133. elements (primitives) that define the %vector feature;</dd>
  134. <dt><b>topo</b></dt>
  135. <dd>binary topology file describes the spatial relationships between the
  136. map's graphic elements;</dd>
  137. <dt><b>hist</b></dt>
  138. <dd>history ASCII file with complete commands that were used to
  139. create the %vector map, as well as the name and date/time of the map
  140. creation;</dd>
  141. <dt><b>cidx</b></dt>
  142. <dd>binary category index file which is used to %link the %vector
  143. object IDs to the attribute table rows;</dd>
  144. <dt><b>dbln</b></dt>
  145. <dd>ASCII file which contains definition(s) of %link to attribute
  146. storage in database (DBMS).</dd>
  147. </dl>
  148. <!-- original:
  149. http://trac.osgeo.org/grass/browser/grass-web/trunk/images/loc_struct.odg
  150. -->
  151. \image html "loc_struct.png" "Diagram of GRASS file structure"
  152. \section Compiling_and_Installing_GRASS_Modules Compiling and Installing GRASS Modules
  153. GRASS modules are compiled and installed using the UNIX <tt>make</tt>
  154. command, which reads a file named <tt>Makefile</tt> (see \ref
  155. Multiple_Architecture_Conventions for more information) and then runs
  156. the compiler. The GRASS compilation process allows for
  157. multiple-architecture compilation from a single copy of the source
  158. code (for instance, if the source code is NFS mounted to various
  159. machines with differing architectures). This chapter assumes that the
  160. programmer is familiar with <tt>make</tt> and its accompanying
  161. Makefile.
  162. <!--
  163. \todo Explain ''auto-conf''
  164. \todo Include contents of SUBMITTING and INSTALL files from source code
  165. -->
  166. To compile enter following:
  167. \verbatim
  168. ./configure
  169. make
  170. make install
  171. \endverbatim
  172. Then the code will be compiled into "/usr/local/grass-7.x.y" directory. The start
  173. script "grass7x" will be placed into "/usr/local/bin/".
  174. Optionally other target directories can be specified while "configuring":
  175. \verbatim
  176. ./configure --prefix=/opt/grass-7.x.y --with-bindir=/usr/bin
  177. make
  178. make install
  179. \endverbatim
  180. This will store the GRASS binaries into the directory
  181. "/opt/grass-7.x.y" and the script mentioned above into "/usr/bin".
  182. The script "make" is required to compile single modules. The
  183. compilation process and requirements are discussed in more detail now.
  184. \subsection Makefile_Variables Makefile Variables
  185. \todo Update the list.
  186. <b>GRASS Libraries</b>. The following variables name the various GRASS
  187. libraries:
  188. - <i>GISLIB</i> - This names the <b>GIS Library</b>, which is the
  189. principal GRASS library. See \ref gislib for details about this
  190. library, and \ref Loading_the_GIS_Library for a sample Makefile which
  191. loads this library.
  192. - <i>SEGMENTLIB</i> - This names the <b>Segment Library</b>, which
  193. manages large matrix data. See \ref segmentlib for details about this
  194. library, and \ref Loading_the_Segment_Library for a sample
  195. <i>Makefile</i> which loads this library.
  196. - <i>RASTERLIB</i> - This names the <b>Raster Library</b>, which is
  197. the principal GRASS library for raster data access. See \ref rasterlib
  198. for details about this library, and \ref Loading_the_Raster_Library
  199. for a sample <i>Makefile</i> which loads this library.
  200. - <i>VECTORLIB</i> - This names the <b>Vector Library</b>, which is
  201. the principal GRASS library for vector data access. See \ref vectorlib
  202. for details about this library, and \ref Loading_the_Vector_Library
  203. for a sample <i>Makefile</i> which loads this library.
  204. - <i>DISPLAYLIB</i> - This names the <b>Display Library</b>, which
  205. communicates with GRASS graphics drivers. See \ref displaylib for
  206. details about this library, and \ref
  207. Loading_the_Display_Library for a sample <i>Makefile</i>
  208. which loads this library.
  209. <b>UNIX Libraries:</b> The following variables name some useful UNIX
  210. system libraries:
  211. - <i>MATHLIB</i> - This names the math library. It should be used
  212. instead of the -lm loader option.
  213. <b>Compiler and loader variables.</b> The following variables are
  214. related to compiling and loading C programs:
  215. - <i>EXTRA\_CFLAGS</i> - This variable can be used to add additional
  216. options to <tt>$CFLAGS</tt>. It has no predefined values. It is
  217. usually used to specify additional -I include directories, or -D
  218. preprocessor defines.
  219. \subsection Constructing_a_Makefile Constructing a Makefile
  220. The complete syntax for a <i>Makefile</i> is discussed in the UNIX
  221. documentation for <tt>make</tt> and will not be repeated here. The
  222. essential idea is that a target (e.g. a GRASS module) is to be built
  223. from a list of dependencies (e.g. object files, libraries, etc.). The
  224. relationship between the target, its dependencies, and the rules for
  225. constructing the target is expressed according to the following
  226. syntax:
  227. \code
  228. target: dependencies
  229. actions
  230. more actions
  231. \endcode
  232. If the target does not exist, or if any of the dependencies have a
  233. newer date than the target (i.e., have changed), the actions will be
  234. executed to build the target. The actions must be indented using a
  235. TAB. <tt>make</tt> is picky about this. It does not like spaces in
  236. place of the TAB.
  237. \section Multiple_Architecture_Conventions Multiple-Architecture Conventions
  238. The following conventions allow for multiple architecture compilation
  239. on a machine that uses a common or networked GRASS source code
  240. directory tree.
  241. Object files and library archives are compiled into subdirectories
  242. that represent the architecture that they were compiled on. These
  243. subdirectories are created in the $SRC directory as OBJ.<tt>arch</tt>
  244. and LIB.<tt>arch</tt>, where <tt>arch</tt> represents the architecture
  245. of the compiling machine. Thus, for example, $SRC/OBJ.sun4 would
  246. contain the object files for Sun/4 and SPARC architectures, and
  247. <tt>$SRC/LIB.686-pc-linux-gnu</tt> would contain library archives for
  248. Linux architectures. Likewise, <tt>$SRC/OBJ.686-pc-linux-gnu</tt>
  249. would contain the object files for Linux architectures, and
  250. <tt>$SRC/LIB.686-pc-linux-gnu</tt> would contain library archives for
  251. Linux architectures.
  252. Note that 'arch' is defined for a specific architecture during setup
  253. and compilation of GRASS, it is not limited to sun4 or any specific
  254. string.
  255. \section vectmodules Vector modules and their parameters/flags
  256. A module is a GRASS command invoked by the user.
  257. \subsection vectmodules_oper Modules operation
  258. Each module which modifies and writes data must read from <b>input</b>
  259. and write to <b>output</b> so that data may not be lost. For example
  260. <tt>v.spag</tt> works on <b>map</b> at in GRASS GIS 5.0 but if program
  261. (system) crashes or threshold was specified incorrectly and vector was
  262. not backuped, data were lost. In this case <b>map</b> option should
  263. be replaced by <b>input</b> and <b>output</b>.
  264. Topology is always built by default if the coor file was modified.
  265. Dimensionality is generally kept. Input 2D vector is written as 2D, 3D
  266. as 3D. There are a few modules which change the dimension on purpose.
  267. \subsection vectmodulesopt Modules parameters/flags
  268. Flags:
  269. - <b>-b</b> do not build topo file; by default topo file is written
  270. - <b>-t</b> create new table, default
  271. - <b>-u</b> don't create new table
  272. - <b>-z</b> write 3D vector map (if input was 2D)
  273. Parameters:
  274. - <b>map</b> input vector map for modules without output
  275. - <b>input</b> input vector map
  276. - <b>output</b> output vector map
  277. - <b>type</b> type of elements: point,line,boundary,centroid,area
  278. - <b>cat</b> category or category list (example: 1,5,9-13,35)
  279. - <b>layer</b> layer number or name
  280. - <b>where</b> condition of SQL statement for selection of records
  281. - <b>column</b> column name (in external table)
  282. */