grasslib.dox 14 KB

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