grasslib.dox 14 KB

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