rasterlib.dox 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171
  1. /*! \page rasterlib GRASS Raster Library
  2. <!-- * doxygenized from "GRASS 5 Programmer's Manual"
  3. by M. Neteler 2/2004, 8/2005, 2006
  4. * updated to GRASS 7 by Martin Landa
  5. -->
  6. by GRASS Development Team (http://grass.osgeo.org)
  7. <b>TODO: Needs to be cleaned up. The upper GRASS 4.x and the lower
  8. GRASS 5.x/6.x parts need to me merged and updated to GRASS 7</b>
  9. \section gisrastintro GRASS Raster Map Processing
  10. This library provides a suite of routines which process raster map file.
  11. The processing of raster map files consists of determining which
  12. raster map file or files are to be processed (specified on the module
  13. command line), locating the raster map file in the database, opening the
  14. raster files, dynamically allocating i/o buffers, reading or writing
  15. the raster files, closing the raster files, and creating support files
  16. for newly created raster maps.
  17. Raster map data can be of type CELL, FCELL or DCELL, they are defined
  18. in "gis.h". CELL is a 32-bit signed integer, FCELL is an IEEE
  19. single-precision floating-point, and DCELL is an IEEE double-precision
  20. floating-point. 3D rasters (grid3d) is treated as DCELL (see related
  21. library).
  22. \section Finding_Raster_Files_in_the_Database Finding Raster Files in the Database
  23. GRASS allows the user to specify raster map names (or any other
  24. GIS database file) either as a simple <em>unqualified</em> name, such as
  25. "soils", or in case of input raster maps also as a <em>fully qualified</em>
  26. name, such as "soils@mapset", where <i>mapset</i> is the mapset where the raster
  27. map is to be found. Often only the unqualified raster map name is
  28. provided on the command line and searched in all mapsets indicated in
  29. the mapset search path (SEARCH_PATH file in the actual mapset; managed
  30. with <tt>g.mapsets</tt> command).
  31. The following routines search the database for raster map files:
  32. - G_find_raster()
  33. Looks for the raster file in the database. If found, the mapset where
  34. the raster file lives is returned. If not found, the NULL pointer is
  35. returned. If the user specifies a fully qualified raster map name which
  36. exists, then G_find_raster() modifies <i>name</i> by removing
  37. the "@<I>mapset</I>".
  38. For example, to find a raster map in all mapsets listed the mapset search
  39. path:
  40. \code
  41. char name[GNAME_MAX];
  42. char *mapset;
  43. if ((mapset = G_find_raster(name,"")) == NULL)
  44. /* not found */
  45. \endcode
  46. To check that the raster map exists in the current mapset:
  47. \code
  48. char name[GNAME_MAX];
  49. if (G_find_raster(name, G_mapset()) == NULL)
  50. /* not found */
  51. \endcode
  52. \section Opening_an_Existing_Raster_File Opening an Existing Raster File
  53. The following routine opens the raster map file for <em>reading</em>.
  54. - Rast_open_old()
  55. This routine opens the raster map in given mapset for reading. A
  56. nonnegative file descriptor is returned if the open is
  57. successful. Otherwise a diagnostic message is printed and a negative
  58. value is returned. This routine does quite a bit of work. Since GRASS
  59. users expect that all raster maps will be resampled into the current
  60. region (nearest neighbor method), the resampling index for the raster
  61. map is prepared by this routine after the map is opened. The resampling
  62. is based on the active module region. Preparation required for reading
  63. the various raster map formats (CELL, FCELL, DCELL) is also done.
  64. \section Creating_and_Opening_New_Raster_Files Creating and Opening New Raster Files
  65. The following routines create a new raster map in the current
  66. mapset and open it for <em>writing</em>. G_legal_filename() should be
  67. called first to make sure that raster map name is a valid name.
  68. <b>Note:</b> It is not an error for raster map to already exist. New
  69. raster maps are actually created as temporary files and moved into
  70. the cell or fcell directory when closed. This allows an existing raster map
  71. to be read at the same time that it is being rewritten. G_find_raster()
  72. could be used to see if raster map already exists.
  73. <b>Warning:</b> However, there is a subtle trap. The temporary file,
  74. which is created using G_tempfile(), is named using the current
  75. process id. If the new raster file is opened by a parent process which
  76. exits after creating a child process using fork(), the raster file may
  77. never get created since the temporary file would be associated with
  78. the parent process, not the child. GRASS management automatically
  79. removes temporary files associated with processes that are no longer
  80. running. If fork() must be used, the safest course of action is to
  81. create the child first, then open the raster file (see the discussion
  82. under G_tempfile() for more details).
  83. - Rast_open_new()
  84. - Rast_open_c_new()
  85. - Rast_open_fp_new()
  86. Creates and opens the raster map for writing by Rast_put_row() which
  87. writes the file row by row in <b>sequential</b> order. The raster file data
  88. will be compressed as it is written. A nonnegative file descriptor is
  89. returned if the open is successful. Otherwise a diagnostic message is
  90. printed and a negative value is returned.
  91. - Rast_open_new_uncompressed()
  92. - Rast_open_c_new_uncompressed()
  93. - Rast_open_fp_new_uncompressed()
  94. Creates and opens the raster file for writing by Rast_put_row() which
  95. writes the file row by row in sequential order. The raster file will
  96. be in uncompressed format when closed. A nonnegative file descriptor
  97. is returned if the open is successful. Otherwise a warning message is
  98. printed on stderr and a negative value is returned.
  99. General use of this routine is not recommended. This routine is
  100. provided so the <tt>r.compress</tt> module can create uncompressed
  101. raster files.
  102. \section Allocating_Raster_I_O_Buffers Allocating Raster I/O Buffers
  103. Since there is no predefined limit for the number of columns in the
  104. region, buffers which are used for reading and writing raster data
  105. must be dynamically allocated.
  106. - Rast_allocate_buf()
  107. - Rast_allocate_c_buf()
  108. - Rast_allocate_f_buf()
  109. - Rast_allocate_d_buf()
  110. This routine allocates a buffer of type CELL/FCELL/DCELL just large enough
  111. to hold one row of raster data (based on the number of columns in the active
  112. region).
  113. \code
  114. int input_fd;
  115. char inmap;
  116. RASTER_MAP_TYPE data_type;
  117. input_fd = Rast_open_old(inmap, "");
  118. data_type = Rast_get_map_type(input_fd);
  119. cell = Rast_allocate_buf(data_type);
  120. \endcode
  121. <i>FIXME 7/2009: next still true?</i>
  122. If larger buffers are required, the routine G_malloc() can be
  123. used.
  124. If sufficient memory is not available, an error message is printed and
  125. exit() is called.
  126. - G_zero_buf()
  127. This routines assigns each member of the raster buffer array to zero.
  128. It assumes that the buffer has been allocated using
  129. Rast_allocate_c_buf().
  130. \section Reading_Raster_Files Reading Raster Files
  131. Raster data can be thought of as a two-dimensional matrix. The
  132. routines described below read one full row of the matrix. It should be
  133. understood, however, that the number of rows and columns in the matrix
  134. is determined by the region, not the raster file itself. Raster data
  135. is always read resampled (nearest neighbor) into the region. This allows
  136. the user to specify the coverage of the database during analyses. It also
  137. allows databases to consist of raster files which do not cover exactly the
  138. same area, or do not have the same grid cell resolution. When raster
  139. files are resampled into the region, they all "look" the same.
  140. <b>Note:</b> The rows and columns are specified "C style", i.e.,
  141. starting with 0.
  142. - Rast_get_row()
  143. This routine reads the specified <i>row</i> from the raster file open
  144. on file descriptor (as returned by Rast_open_old()) into the
  145. buffer. The buffer must be dynamically allocated large enough to hold
  146. one full row of raster data. It can be allocated using
  147. Rast_allocate_buf(). This routine prints a diagnostic message and
  148. returns -1 if there is an error reading the raster file. Otherwise a
  149. nonnegative value is returned.
  150. - Rast_get_row_nomask()
  151. This routine reads the specified row from the raster file open on file
  152. descriptor into the buffer like Rast_get_row() does. The difference
  153. is that masking is suppressed. If the user has a mask set,
  154. Rast_get_row() will apply the mask but Rast_get_row_nomask() will
  155. ignore it. This routine prints a diagnostic message and returns -1 if
  156. there is an error reading the raster file. Otherwise a nonnegative
  157. value is returned.
  158. <b>Note:</b> Ignoring the mask is not generally acceptable. Users
  159. expect the mask to be applied. However, in some cases ignoring the
  160. mask is justified. For example, the GRASS modules <tt>r.describe</tt>,
  161. which reads the raster file directly to report all data values in a
  162. raster file, and <tt>r.slope.aspect</tt>, which produces slope and
  163. aspect from elevation, ignore both the mask and the region. However,
  164. the number of GRASS modules which do this should be minimal. See \ref
  165. Mask for more information about the mask.
  166. \subsection Writing_Raster_Files Writing Raster Files
  167. - Rast_put_row()
  168. This routine writes one row of raster data from buffer to the raster
  169. file open on file descriptor. The raster file must have been opened
  170. with Rast_open_new(). The buffer must have been allocated large
  171. enough for the region, perhaps using Rast_allocate_buf(). If there
  172. is an error writing the raster file, a warning message is printed and
  173. -1 is returned. Otherwise 1 is returned.
  174. <b>Note:</b> The rows are written in <b>sequential</b> order. The
  175. first call writes row 0, the second writes row 1, etc. The following
  176. example assumes that the raster file is to be created:
  177. \code
  178. int fd, row, nrows, ncols;
  179. CELL *buf;
  180. RASTER_MAP_TYPE data_type;
  181. fd = Rast_open_old(inmap, ""); /*...data for the row */
  182. data_type = Rast_get_map_type(fd);
  183. Rast_put_row(fd, buf, data_type);
  184. \endcode
  185. \subsection Closing_Raster_Files Closing Raster Files
  186. All raster files are closed by one of the following routines, whether
  187. opened for reading or for writing.
  188. - Rast_close()
  189. The raster file opened on file descriptor is closed. Memory allocated
  190. for raster processing is freed. If open for writing, skeletal support
  191. files for the new raster file are created as well.
  192. <b>Note:</b> If a module wants to explicitly write support files
  193. (e.g., a specific color table) for a raster file it creates, it must
  194. do so after the raster file is closed. Otherwise the close will
  195. overwrite the support files. See \ref Raster_Map_Layer_Support_Routines
  196. for routines which write raster support files.
  197. - Rast_unopen()
  198. The raster file opened on file descriptor is closed. Memory allocated
  199. for raster processing is freed. If open for writing, the raster file
  200. is not created and the temporary file created when the raster file was
  201. opened is removed (see \ref Creating_and_Opening_New_Raster_Files).
  202. This routine is useful when errors are detected and it is desired to
  203. not create the new raster file. While it is true that the raster file
  204. will not be created if the module exits without closing the file, the
  205. temporary file will not be removed at module exit. GRASS database
  206. management will eventually remove the temporary file, but the file can
  207. be quite large and will take up disk space until GRASS does remove
  208. it. Use this routine as a courtesy to the user.
  209. \section Raster_Map_Layer_Support_Routines Raster Map Layer Support Routines
  210. GRASS map layers have a number of support files associated with
  211. them. These files are discussed in detail in \ref Raster_Maps. The
  212. support files are the <em>raster header</em>, the <em>category</em>
  213. file, the <em>color</em> table, the <em>history</em> file, and the
  214. <em>range</em> file. Each support file has its own data structure and
  215. associated routines.
  216. \section Raster_Header_File Raster Header File
  217. The raster header file contains information describing the geographic
  218. extent of the map layer, the grid cell resolution, and the format used
  219. to store the data in the raster file. The format of this file is
  220. described in \ref Raster_Header_Format. The routines described below
  221. use the <i>Cell_head</i> structure which is shown in detail in \ref
  222. GIS_Library_Data_Structures.
  223. - Rast_get_cellhd()
  224. The raster header for the raster file in the specified mapset is read
  225. into the <em>cellhd</em> structure. If there is an error reading the
  226. raster header file, a diagnostic message is printed and -1 is
  227. returned. Otherwise, 0 is returned.
  228. <b>Note:</b> If the raster file is a reclass file, the raster header
  229. for the referenced raster file is read instead. See \ref Reclass_Format
  230. for information about reclass files, and Rast_is_reclass()
  231. for distinguishing reclass files from regular raster files.
  232. <b>Note:</b> It is not necessary to get the raster header for a map
  233. layer in order to read the raster file data. The routines which read
  234. raster file data automatically retrieve the raster header information
  235. and use it for resampling the raster file data into the active
  236. region. If it is necessary to read the raster file directly without
  237. resampling into the active region, then the raster header can be used
  238. to set the active region using G_set_window().
  239. - G_adjust_Cell_head()
  240. This function fills in missing parts of the input cell header (or
  241. region). It also makes projection-specific adjustments.
  242. - Rast_put_cellhd()
  243. This routine writes the information from the Cell_head structure to
  244. the raster header file for the map layer in the current mapset. If
  245. there was an error creating the raster header, -1 is returned. No
  246. diagnostic is printed. Otherwise, 1 is returned to indicate success.
  247. <b>Note:</b> Programmers should have no reason to use this routine. It
  248. is used by Rast_close() to give new raster files correct header
  249. files, and by the <tt>r.support</tt> module to give users a means of
  250. creating or modifying raster headers.
  251. - Rast_is_reclass()
  252. This function determines if the raster file is a reclass file. Returns
  253. 1 if raster file is a reclass file, 0 if it is not, and -1 if there
  254. was a problem reading the raster header.
  255. - Rast_is_reclassed_to()
  256. This function generates a child reclass maps list from the
  257. cell_misc/reclassed_to file which stores this list. The
  258. cell_misc/reclassed_to file is written by
  259. Rast_put_reclass(). Rast_is_reclassed_to() is used by <tt>g.rename</tt>,
  260. <tt>g.remove</tt> and <tt>r.reclass</tt> to prevent accidentally
  261. deleting the parent map of a reclassed raster map.
  262. \section Raster_Category_File Raster Category File
  263. GRASS map layers have category labels associated with them. The
  264. category file is structured so that each category in the raster file
  265. can have a one-line description. The format of this file is described
  266. in \ref Raster_Category_File_Format.
  267. The routines described below manage the category file. Some of them
  268. use the <i>Categories</i> structure which is described in \ref
  269. GIS_Library_Data_Structures.
  270. \section Reading_and_Writing_the_Raster_Category_File Reading and Writing the Raster Category File
  271. The following routines read or write the category file itself:
  272. - Rast_read_cats()
  273. The category file for raster file is read into the <i>cats</i>
  274. structure. If there is an error reading the category file, a
  275. diagnostic message is printed and -1 is returned. Otherwise, 0 is
  276. returned.
  277. - Rast_write_cats()
  278. Writes the category file for the raster file in the current mapset
  279. from the <i>cats</i> structure. Returns 1 if successful. Otherwise, -1
  280. is returned (no diagnostic is printed).
  281. - Rast_get_title()
  282. If only the map layer title is needed, it is not necessary to read the
  283. entire category file into memory. This routine gets the title for
  284. raster file directly from the category file, and returns a pointer to
  285. the title. A legal pointer is always returned. If the map layer does
  286. not have a title, then a pointer to the empty string "" is returned.
  287. - Rast_put_title()
  288. If it is only desired to change the title for a map layer, it is not
  289. necessary to read the entire category file into memory, change the
  290. title, and rewrite the category file. This routine changes the title
  291. for the raster file in the current mapset directly in the category
  292. file. It returns a pointer to the title.
  293. \section Querying_and_Changing_the_Categories_Structure Querying and Changing the Categories Structure
  294. The following routines query or modify the information contained in
  295. the category structure:
  296. - Rast_get_cat()
  297. This routine looks up category in the cats structure and returns a
  298. pointer to a string which is the label for the category. A legal
  299. pointer is always returned. If the category does not exist in cats
  300. then a pointer to the empty string "" is returned.
  301. <b>Warning:</b> The pointer that is returned points to a hidden static
  302. buffer. Successive calls to Rast_get_cat() overwrite this buffer.
  303. - Rast_get_cats_title()
  304. Map layers store a one-line title in the category structure as
  305. well. This routine returns a pointer to the title contained in the
  306. cats structure. A legal pointer is always returned. If the map layer
  307. does not have a title, then a pointer to the empty string "" is
  308. returned.
  309. - Rast_init_cats()
  310. To construct a new category file, the structure must first be
  311. initialized. This routine initializes the cats structure, and copies
  312. the title into the structure.
  313. For example:
  314. \code
  315. struct Categories cats;
  316. Rast_init_cats ((CELL) 0, "", &cats);
  317. \endcode
  318. - Rast_set_cat()
  319. Copies the label into the cats structure for category.
  320. - Rast_set_cats_title()
  321. Copies the title is copied into the cats structure.
  322. - Rast_free_cats()
  323. Frees memory allocated by Rast_read_cats(), Rast_init_cats() and
  324. Rast_set_cat().
  325. \section Raster_Color_Table Raster Color Table
  326. GRASS map layers have colors associated with them. The color tables
  327. are structured so that each category in the raster file has its own
  328. color. The format of this file is described in
  329. \ref Raster_Color_Table_Format.
  330. The routines that manipulate the raster color file use the
  331. <i>Colors</i> structure which is described in detail in
  332. \ref GIS_Library_Data_Structures.
  333. \section Reading_and_Writing_the_Raster_Color_File Reading and Writing the Raster Color File
  334. The following routines read, create, modify, and write color tables.
  335. - Rast_read_colors()
  336. The color table for the raster file in the specified mapset is read
  337. into the <em>colors</em> structure. If the data layer has no color
  338. table, a default color table is generated and 0 is returned. If there
  339. is an error reading the color table, a diagnostic message is printed
  340. and -1 is returned. If the color table is read ok, 1 is returned.
  341. - Rast_write_colors()
  342. Write map layer color table. The color table is written for the raster
  343. file in the specified mapset from the <em>colors</em> structure. If
  344. there is an error, -1 is returned. No diagnostic is
  345. printed. Otherwise, 1 is returned.
  346. The <em>colors</em> structure must be created properly, i.e.,
  347. Rast_init_colors() to initialize the structure and Rast_add_color_rule() to
  348. set the category colors.
  349. <b>Note:</b> The calling sequence for this function deserves special
  350. attention. The <em>mapset</em> parameter seems to imply that it is
  351. possible to overwrite the color table for a raster file which is in
  352. another mapset. However, this is not what actually happens. It is very
  353. useful for users to create their own color tables for raster files in
  354. other mapsets, but without overwriting other users' color tables for
  355. the same raster file. If <em>mapset</em> is the current mapset, then
  356. the color file for <em>name</em> will be overwritten by the new color
  357. table. But if <em>mapset</em> is not the current mapset, then the
  358. color table is actually written in the current mapset under the
  359. <tt>colr2</tt> element as: <tt>colr2/mapset/name</tt>.
  360. \section Lookup_Up_Raster_Colors Lookup Up Raster Colors
  361. These routines translates raster values to their respective colors.
  362. - Rast_lookup_colors()
  363. Extracts colors for an array of raster values. The colors from the
  364. raster array are stored in the red, green, and blue arrays.
  365. <b>Note:</b> The red, green, and blue intensities will be in the range
  366. 0-255.
  367. - Rast_get_color()
  368. Get a category color. The red, green, and blue intensities for the
  369. color associated with category are extracted from the colors
  370. structure. The intensities will be in the range 0-255.
  371. \section Creating_and_or_Modifying_the_Color_Table Creating and/or Modifying the Color Table
  372. These routines allow the creation of customized color tables as well as the
  373. modification of existing tables.
  374. - Rast_init_colors()
  375. Initialize <i>colors</i> structure for subsequent calls
  376. Rast_add_color_rule() and Rast_set_color().
  377. - Rast_add_color_rule()
  378. This is the heart and soul of the color logic. It adds a color
  379. rule to the <em>colors</em> structure. The colors defined by the red,
  380. green, and blue values are assigned to the categories
  381. respectively. Colors for data values between two categories are not
  382. stored in the structure but are interpolated when queried by
  383. Rast_lookup_colors() and Rast_get_color(). The color components must be in the
  384. range 0-255.
  385. For example, to create a linear grey scale for the range 200-1000:
  386. \code
  387. struct Colors colr;
  388. Rast_init_colors (&colr) ;
  389. Rast_add_color_rule ((CELL) 200, 0,0,0,(CELL) 1000, 255,255,255) ;
  390. \endcode
  391. The programmer is encouraged to review \ref Raster_Color_Table_Format.
  392. <b>Note:</b> The <em>colors</em> structure must have been initialized
  393. by Rast_init_colors(). See \ref Predefined_Color_Tables for routines to
  394. build some predefined color tables.
  395. - Rast_set_color()
  396. Set a category color. The red, green, and blue intensities for the
  397. color associated with category The intensities must be in the range
  398. 0-255. Values below zero are set as zero, values above 255 are set as
  399. 255.
  400. <b>Warning:</b> Use of this routine is discouraged because it defeats
  401. the new color logic. It is provided only for backward
  402. compatibility. Overuse can create large color
  403. tables. Rast_add_color_rule() should be used whenever possible.
  404. <b>Note:</b> The <em>colors</em> structure must have been initialized
  405. by Rast_init_color().
  406. - Rast_get_color_range()
  407. - Rast_get_d_color_range()
  408. Get color range. Gets the minimum and maximum raster values that have
  409. colors associated with them.
  410. - Rast_free_colors()
  411. Free dynamically allocated memory associated with the <em>colors</em>
  412. structure.
  413. <b>Note:</b> This routine may be used after Rast_read_colors() as well as
  414. after Rast_init_colors().
  415. \section Predefined_Color_Tables Predefined Color Tables
  416. The following routines generate entire color tables. The tables are
  417. loaded into a <i>colors</i> structure based on a range of category
  418. values from minimum to maximum value. The range of values for a raster
  419. map can be obtained, for example, using Rast_read_range().
  420. <b>Note:</b> The color tables are generated without information about
  421. any particular raster file.
  422. These color tables may be created for a raster map, but they may also
  423. be generated for loading graphics colors. These routines return -1 if
  424. minimum value is greater than maximum value, 1 otherwise.
  425. - Rast_make_aspect_colors()
  426. Generates a color table for aspect data.
  427. - Rast_make_ramp_colors()
  428. Generates a color table with 3 sections: red only, green only, and
  429. blue only, each increasing from none to full intensity. This table is
  430. good for continuous data, such as elevation.
  431. - Rast_make_wave_colors()
  432. Generates a color table with 3 sections: red only, green only, and
  433. blue only, each increasing from none to full intensity and back down
  434. to none. This table is good for continuous data like elevation.
  435. - Rast_make_grey_scale_colors()
  436. Generates a grey scale color table. Each color is a level of grey,
  437. increasing from black to white.
  438. - Rast_make_rainbow_colors()
  439. Generates a "shifted" rainbow color table - yellow to green to cyan to
  440. blue to magenta to red. The color table is based on rainbow
  441. colors. (Normal rainbow colors are red, orange, yellow, green, blue,
  442. indigo, and violet.) This table is good for continuous data, such as
  443. elevation.
  444. - Rast_make_random_colors()
  445. Generates random colors. Good as a first pass at a color table for
  446. nominal data.
  447. - Rast_make_ryg_colors()
  448. Generates a color table that goes from red to yellow to green.
  449. - Rast_make_gyr_colors()
  450. Generates a color table that goes from green to yellow to red.
  451. - Rast_make_histogram_eq_colors()
  452. Generates a histogram contrast-stretched grey scale color table that goes
  453. from the, histogram information.
  454. \section Raster_History_File Raster History File
  455. The history file contains documentary information about the raster
  456. file: who created it, when it was created, what was the original data
  457. source, what information is contained in the raster file, etc. This
  458. file is discussed in \ref Raster_History_File_Format.
  459. The following routines manage this file. They use the <em>History</em>
  460. structure which is described in \ref GIS_Library_Data_Structures.
  461. <b>Note:</b> This structure has existed relatively unmodified since
  462. the inception of GRASS. It is in need of overhaul. Programmers should
  463. be aware that future versions of GRASS may no longer support either
  464. the routines or the data structure which support the history file.
  465. - Rast_read_history()
  466. Read raster history file. This routine reads the history file for the
  467. raster map into the <em>history</em> structure. A diagnostic message
  468. is printed and -1 is returned if there is an error reading the history
  469. file. Otherwise, 0 is returned.
  470. - Rast_write_history()
  471. Write raster history file. This routine writes the history file for
  472. the raster map in the current mapset from the <em>history</em>
  473. structure. A diagnostic message is printed and -1 is returned if there
  474. is an error writing the history file. Otherwise, 0 is returned.
  475. <b>Note:</b> The <em>history</em> structure should first be
  476. initialized using Rast_short_history().
  477. - Rast_short_history()
  478. Initialize history structureThis routine initializes the
  479. <em>history</em> structure, recording the date, user, module name and
  480. the raster map.
  481. <b>Note:</b> This routine only initializes the data structure. It does
  482. not write the history file.
  483. \section Raster_Range_File Raster Range File
  484. The following routines manage the raster range file. This file
  485. contains the minimum and maximum values found in the raster file. The
  486. format of this file is described in \ref Raster_Range_File_Format.
  487. The routines below use the <i>Range</i> data structure which is
  488. described in \ref GIS_Library_Data_Structures.
  489. - Rast_read_range()
  490. Reads raster range. This routine reads the range information for the
  491. raster map into the <i>range</i> structure. A diagnostic message is
  492. printed and -1 is returned if there is an error reading the range
  493. file. Otherwise, 0 is returned.
  494. - Rast_write_range()
  495. Write raster range file. This routine writes the range information for
  496. the raster map in the current mapset from the <i>range</i>
  497. structure. A diagnostic message is printed and -1 is returned if there
  498. is an error writing the range file. Otherwise, 0 is returned.
  499. The range structure must be initialized and updated using the following
  500. routines:
  501. - Rast_init_range()
  502. Initializes the <i>range</i> structure for updates by Rast_update_range()
  503. and Rast_row_update_range().
  504. - Rast_update_range()
  505. Compares the category value with the minimum and maximum values in the
  506. <i>range</i> structure, modifying the range if the value extends the
  507. range.
  508. - Rast_row_update_range()
  509. This routine updates the range data just like Rast_update_range().
  510. The range structure is queried using the following routine:
  511. - Rast_get_range_min_max()
  512. Get range minimum and maximum value.
  513. \section Raster_Histograms Raster Histograms
  514. The following routines provide a relatively efficient mechanism for
  515. computing and querying a histogram of raster data. They use the
  516. <b>Cell_stats</b> structure to hold the histogram information. The
  517. histogram is a count associated with each unique raster value
  518. representing the number of times each value was inserted into the
  519. structure.
  520. These next two routines are used to manage the Cell_stats structure:
  521. - Rast_init_cell_stats()
  522. Initialize cell stats, This routine, which must be called first,
  523. initializes the Cell_stats structure.
  524. - Rast_free_cell_stats()
  525. Free cell stats. The memory associated with structure is freed. This
  526. routine may be called any time after calling Rast_init_cell_stats().
  527. This next routine stores values in the histogram:
  528. - Rast_update_cell_stats()
  529. Adds data to cell stats. Once all values are stored, the structure may
  530. be queried either randomly (i.e., search for a specific raster value) or
  531. sequentially (retrieve all raster values, in ascending order, and
  532. their related count):
  533. - Rast_find_cell_stat()
  534. Random query of cell stats. This routine allows a random query of the
  535. Cell_stats structure. The routine returns 1 if <B>cat</B> was found in
  536. the structure, 0 otherwise.
  537. Sequential retrieval is accomplished using these next 2 routines:
  538. - Rast_rewind_cell_stats()
  539. Reset/rewind cell stats. The structure is rewound (i.e., positioned at
  540. the first raster category) so that sorted sequential retrieval can
  541. begin.
  542. - Rast_next_cell_stat()
  543. Retrieve sorted cell stats. Retrieves the next <i>cat, count</i>
  544. combination from the structure. Returns 0 if there are no more items,
  545. non-zero if there are more.
  546. For example:
  547. \code
  548. struct Cell_stats s;
  549. CELL cat;
  550. long count;
  551. /* updating s occurs here */
  552. Rast_rewind_cell_stats(&s);
  553. while(Rast_next_cell_stat(&cat, &count, &s))
  554. fprintf(stdout, "%ld %ld\n", (long) cat, count);
  555. \endcode
  556. \section GRASS_5_raster_API GRASS 5 raster API [needs to be merged
  557. into above sections]
  558. \subsection The_CELL_Data_Type The CELL Data Type
  559. GRASS integer raster map data is defined to be of type CELL. This data
  560. type is defined in the "gis.h" header file. Programmers must declare
  561. all variables and buffers which will hold raster data or category
  562. codes as type CELL. Under GRASS the CELL data type is declared to be
  563. "int", but the programmer should not assume this. What should be
  564. assumed is that CELL is a signed integer type. It may be changed
  565. sometime to short or long. This implies that use of CELL data with
  566. routines which do not know about this data type (e.g.,
  567. <tt>fprintf(stdout, ...), sscanf()</tt>, etc.) must use an
  568. intermediate variable of type long. To print a CELL value, it must be
  569. cast to long. For example:
  570. \code
  571. CELL c; /* raster value to be printed */
  572. /* some code to get a value for c */
  573. fprintf(stdout, "%ld\n", (long) c); /* cast c to long to print */
  574. \endcode
  575. To read a CELL value, for example from user typed input, it is
  576. necessary to read into a long variable, and then assign it to the CELL
  577. variable. For example (this example does not check for valid inputs,
  578. EOF, etc., which good code must do):
  579. \code
  580. char userbuf[128];
  581. CELL c;
  582. long x;
  583. fprintf (stdout, "Which category? "); /* prompt user */
  584. gets(userbuf); /* get user response * /
  585. sscanf (userbuf,"%ld", &x); /* scan category into long variable */
  586. c = (CELL) x; /* assign long value to CELL value */
  587. \endcode
  588. Of course, with GRASS library routines that are designed to handle the
  589. CELL type, this problem does not arise. It is only when CELL data must
  590. be used in routines which do not know about the CELL type, that the
  591. values must be cast to or from long.
  592. \subsection 5.0 Changes to <TT>"gis.h"</TT>
  593. The "gis.h" contains 5 new items:
  594. \code
  595. typedef float FCELL;
  596. typedef double DCELL;
  597. typedef int RASTER_MAP_TYPE;
  598. #define CELL_TYPE 0
  599. #define FCELL_TYPE 1
  600. #define DCELL_TYPE 2
  601. \endcode
  602. Also "gis.h" contains the definitions for new structures:
  603. \code
  604. struct FPReclass;
  605. struct FPRange;
  606. struct Quant;
  607. \endcode
  608. Some of the old structures such as
  609. \code
  610. struct Categories
  611. struct Cell_stats;
  612. struct Range;
  613. struct _Color_Rule_;
  614. struct _Color_Info_;
  615. struct Colors;
  616. \endcode
  617. were modified, so it is very important to use functional interface to
  618. access and set elements of these structures instead of accessing
  619. elements of the structures directly. Because some former elements such
  620. as for example <tt>(struct Range range.pmin)</tt> do not exist
  621. anymore. It was made sure non of the former elements have different
  622. meaning, so that the programs which do access the old elements
  623. directly either do not compile or work exactly the same way as prior
  624. to change.
  625. \subsection NULL_value_functions NULL-value functions
  626. - Rast_set_null_value()
  627. Set NULL value. For raster type <tt>CELL_TYPE</tt> use
  628. Rast_set_c_null_value(), for <tt>FCELL_TYPE</tt> Rast_set_f_null_value(),
  629. and for <tt>DCELL_TYPE</tt> Rast_set_d_null_value().
  630. - Rast_insert_null_values()
  631. Insert NULL value. If raster type is <tt>CELL_TYPE</tt> calls
  632. Rast_insert_c_null_values(), <tt>FCELL_TYPE</tt> calls
  633. Rast_insert_f_null_values(), and <tt>DCELL_TYPE</tt> calls
  634. Rast_insert_d_null_values().
  635. - Rast_is_null_value()
  636. Check NULL value. If raster type is <tt>CELL_TYPE</tt>, calls
  637. Rast_is_c_null_value(), <tt>FCELL_TYPE</tt> calls
  638. Rast_is_f_null_value(), and <tt>DCELL_TYPE</tt> calls
  639. Rast_is_d_null_value().
  640. It isn't good enough to test for a particular NaN bit pattern since
  641. the machine code may change this bit pattern to a different NaN. The
  642. test will be
  643. \code
  644. if(fcell == 0.0) return 0;
  645. if(fcell > 0.0) return 0;
  646. if(fcell < 0.0) return 0;
  647. return 1;
  648. \endcode
  649. or (as suggested by Mark Line)
  650. \code
  651. return(FCELL != fcell) ;
  652. \endcode
  653. - Rast_allocate_null_buf()
  654. Allocates an array of char based on the number of columns in the
  655. current region.
  656. - Rast_get_null_value_row()
  657. Reads a row from NULL value bitmap file for the raster map open for
  658. read. If there is no bitmap file, then this routine simulates the read
  659. as follows: non-zero values in the raster map correspond to non-NULL;
  660. zero values correspond to NULL. When MASK exists, masked cells are set
  661. to null.
  662. \subsection Floating_point_and_type_independent_functions Floating-point and type-independent functions
  663. - Rast_maskfd()
  664. Test for current maskreturns file descriptor number if MASK is in use
  665. and -1 if no MASK is in use.
  666. - Rast_map_is_fp()
  667. Returns true(1) if raster map is a floating-point dataset; false(0)
  668. otherwise.
  669. - Rast_map_type()
  670. Returns the storage type for raster map:
  671. - <tt>CELL_TYPE</tt> for integer raster map
  672. - <tt>FCELL_TYPE</tt> for floating-point raster map
  673. - <tt>DCELL_TYPE</tt> for floating-point raster map (double precision)
  674. - Rast_open_new()
  675. Creates new raster map in the current mapset. Calls G_open_map_new()
  676. for raster type <tt>CELL_TYPE</tt>, G_open_fp_map_new() for
  677. floating-point raster map. The use of this routine by applications is
  678. discouraged since its use would override user preferences (what
  679. precision to use).
  680. - Rast_set_fp_type()
  681. This controls the storage type for floating-point raster maps. It
  682. affects subsequent calls to Rast_open_fp_new(). The <em>type</em>
  683. must be one of <tt>FCELL_TYPE</tt> (float) or <tt>DCELL_TYPE</tt>
  684. (double). The use of this routine by applications is discouraged since
  685. its use would override user preferences.
  686. - Rast_open_fp_new()
  687. Creates a new floating-point raster map (in <tt>.tmp</tt>) and returns
  688. a file descriptor. The storage type (float or double) is determined by
  689. the last call to Rast_set_fp_type() or the default (float - unless the
  690. GRASS environmental variable GRASS_FP_DOUBLE is set).
  691. - Rast_allocate_buf()
  692. - Rast_allocate_c_buf()
  693. - Rast_allocate_f_buf()
  694. - Rast_allocate_d_buf()
  695. Allocate an arrays of CELL, FCELL, or DCELL (depending on raster type)
  696. based on the number of columns in the current region.
  697. - Rast_incr_void_ptr()
  698. Advances void pointer by n bytes. Returns new pointer value. Usefull
  699. in raster row processing loops, substitutes
  700. \code
  701. CELL *cell;
  702. cell += n;
  703. \endcode
  704. Now
  705. \code
  706. rast = Rast_incr_void_ptr(rast, Rast_raster_size(data_type));
  707. \endcode
  708. Where <i>rast</i> is void* and data_type is RASTER_MAP_TYPE can be
  709. used instead of rast++.) Very usefull to generalize the row processing
  710. - loop (i.e. void * buf_ptr += Rast_raster_size(data_type))
  711. - Rast_raster_size()
  712. If <i>data_type</i> is CELL_TYPE, returns sizeof(CELL), for FCELL_TYPE
  713. returns sizeof(FCELL), and for <EM>data_type</EM> is DCELL_TYPE,
  714. returns sizeof(DCELL).
  715. - Rast_raster_cmp()
  716. Compares raster values.
  717. - Rast_raster_cpy()
  718. Copies raster values.
  719. - Rast_set_value_c()
  720. If Rast_is_c_null_value() is true, sets value to null value. Converts
  721. CELL value to raster data type value and stores the result. Used for
  722. assigning CELL values to raster cells of any type.
  723. - Rast_set_value_f()
  724. If Rast_is_f_null_value() is true, sets value to null value. Converts
  725. FCELL val to raster data type and stores the result. Used for
  726. assigning FCELL values to raster cells of any type.
  727. - Rast_set_value_d()
  728. If Rast_is_d_null_value() is true, sets value to null value. Converts
  729. DCELL val to raster data type and stores the result. Used for
  730. assigning DCELL values to raster cells of any type.
  731. - Rast_get_value_c()
  732. Retrieves the value of raster type, converts it to CELL type and
  733. returns the result. If null value is stored, returns CELL null
  734. value. Used for retreiving CELL values from raster cells of any type.
  735. Note: when data_type != CELL_TYPE, no quantization is used, only type conversion.
  736. - Rast_get_value_f()
  737. Retrieves the value of raster type, converts it to FCELL type and
  738. returns the result. If null value is stored, returns FCELL null
  739. value. Used for retreiving FCELL values from raster cells of any type.
  740. - Rast_get_value_d()
  741. Retrieves the value of raster type, converts it to DCELL type and
  742. returns the result. If null value is stored, returns DCELL null
  743. value. Used for retreiving DCELL values from raster cells of any type.
  744. - Rast_get_row ()
  745. For CELL_TYPE raster type calls Rast_get_c_row(), FCELL_TYPE calls
  746. Rast_get_f_row(), and DCELL_TYPE Rast_get_d_row().
  747. - Rast_get_row_nomask().
  748. Same as Rast_get_f_row() except no masking occurs.
  749. - Rast_get_f_row()
  750. Read a row from the raster map performing type conversions as
  751. necessary based on the actual storage type of the map. Masking,
  752. resampling into the current region. NULL-values are always embedded
  753. (never converted to a value).
  754. - Rast_get_f_row_nomask()
  755. Same as Rast_get_f_row() except no masking occurs.
  756. - Rast_get_d_row()
  757. Same as Rast_get_f_row() except that the array double.
  758. - Rast_get_d_row_nomask()
  759. Same as Rast_get_d_row() except no masking occurs.
  760. - Rast_get_c_row()
  761. Reads a row of raster data and leaves the NULL values intact. (As
  762. opposed to the deprecated function Rast_get_row() which converts NULL
  763. values to zero.)
  764. <b>Note:</b> When the raster map is old and null file doesn't exist,
  765. it is assumed that all 0-cells are no-data. When map is floating
  766. point, uses quant rules set explicitly by Rast_set_quant_rules or stored
  767. in map's quant file to convert floats to integers.
  768. - Rast_get_c_row_nomask()
  769. Same as Rast_get_c_row() except no masking occurs.
  770. - Rast_put_row()
  771. If raster type is CELL_TYPE, calls Rast_put_c_row(), if FCELL_TYPE, then calls Rast_put_f_row(), and for DCELL_TYPE, calls Rast_put_d_row().
  772. - Rast_put_f_row()
  773. Write the next row of the raster map performing type conversion to the
  774. actual storage type of the resultant map. Keep track of the range of
  775. floating-point values. Also writes the NULL-value bitmap from the
  776. NULL-values embedded in the data array.
  777. - Rast_put_d_row()
  778. Same as Rast_put_f_row() except that the array is double.
  779. - Rast_put_c_row()
  780. Writes a row of raster data and a row of the null-value bitmap, only
  781. treating NULL as NULL. (As opposed to the deprecated function
  782. Rast_put_row() which treats zero values also as NULL.)
  783. - Rast_zero_row()
  784. Depending on raster type zeroes out Rast_window_cols() CELLs, FCELLs, or
  785. DCELLs stored in cell buffer.
  786. - Rast_get_sample()
  787. Extracts a cell value from raster map at given position with nearest neighbor interpolation, bilinear interpolation or cubic interpolation.
  788. \section Upgrades_to_Raster_Functions Upgrades to Raster Functions (comparing to GRASS 4.x)
  789. These routines will be modified (internally) to work with
  790. floating-point and NULL-values.
  791. - Rast_close()
  792. If the map is a new floating point, move the <TT>.tmp</TT> file into
  793. the <TT>fcell</TT> element, create an empty file in the <TT>cell</TT>
  794. directory; write the floating-point range file; write a default
  795. quantization file quantization file is set here to round fp numbers
  796. (this is a default for now). Create an empty category file, with max
  797. cat = max value (for backwards compatibility). Move the <TT>.tmp</TT>
  798. NULL-value bitmap file to the <TT>cell_misc</TT> directory.
  799. - Rast_open_old()
  800. Arrange for the NULL-value bitmap to be read as well as the raster
  801. map. If no NULL-value bitmap exists, arrange for the production of
  802. NULL-values based on zeros in the raster map.
  803. If the map is floating-point, arrange for quantization to integer for
  804. Rast_get_c_row(), et. al., by reading the quantization rules for
  805. the map using Rast_read_quant().
  806. If the programmer wants to read the floating point map using uing
  807. quant rules other than the ones stored in map's quant file, he/she
  808. should call Rast_set_quant_rules() after the call to Rast_open_old().
  809. - Rast_get_row()
  810. If the map is floating-point, quantize the floating-point values to
  811. integer using the quantization rules established for the map when the
  812. map was opened for reading (this quantization is read from
  813. cell_misc/name/f_quant file, but can be reset after opening raster map
  814. by Rast_set_quant_rules()). NULL values are converted to zeros. <b>This
  815. routine is deprecated!!</b>
  816. - Rast_put_row()
  817. Zero values are converted to NULLs. Write a row of the NULL value bit
  818. map. <b>This routine is deprecated!!</b>
  819. \section Null_no_data NULL (no data) handling
  820. The <tt>null</tt> file is stored in <tt>cell_misc/name/null file</tt>.
  821. -2^31 (= 0x80000000 = -2147483648) is the null value for the CELL
  822. type, so you'll never see that value in a map.
  823. The FP nulls are the all-ones bit patterns. These corresponds to NaN
  824. according to the IEEE-754 formats, although it isn't the "default" NaN
  825. pattern generated by most architectures (which is usually 7fc00000 or
  826. ffc00000 for float and 7ff8000000000000 or fff8000000000000 for
  827. double, i.e. an all-ones exponent, the top-bit of the mantissa set,
  828. and either sign).
  829. So far as arithmetic is concerned, any value with an all-ones exponent
  830. and a non-zero mantissa is treated as NaN. But the GRASS
  831. Rast_is_[fd]_null_value() functions only consider the all-ones bit
  832. pattern to be null. I intend to change this in 7.x so that all FP NaN
  833. values are treated as null. This will mean that code which can
  834. generate NaNs doesn't have to explicitly convert them to the GRASS
  835. null value.
  836. <b>Presence or absence of <tt>null</tt> file:</b>
  837. For an integer map, any cells which were null will become zero, but
  838. any zeroes (cells which were previously either null or zero) will be
  839. treated as nulls (this is for compatibility with GRASS 4.x, which
  840. didn't have a <tt>null</tt> file, but typically used zero to indicate
  841. a null value).
  842. For a floating-point map, any cells which were null will become zero
  843. (when writing FP data, a null has a zero written to the fcell/<map>
  844. file, and the corresponding bit is set in the <tt>null</tt> file).
  845. \section Color_Functions Color Functions (new and upgraded)
  846. \subsection Upgraded_Colors_structures Upgraded Colors structures
  847. \code
  848. struct _Color_Rule_
  849. {
  850. struct
  851. {
  852. int version; /* set by read\_colors: -1=old,1=new */
  853. DCELL shift;
  854. int invert;
  855. int is_float; /* defined on floating point raster data? */
  856. int null_set; /* the colors for null are set? */
  857. unsigned char null_red, null_grn, null_blu;
  858. int undef_set; /* the colors for cells not in range are set? */
  859. unsigned char undef_red, undef_grn, undef_blu;
  860. struct _Color_Info_ fixed, modular;
  861. DCELL cmin, cmax;
  862. };
  863. \endcode
  864. \section New_functions_to_support_colors_for_floating_point New functions to support colors for floating-point
  865. - Rast_lookup_colors()
  866. If raster type is CELL_TYPE, calls Rast_lookup_colors(), if FCELL_TYPE,
  867. calls Rast_lookup_f_colors(), and for DCELL_TYPE
  868. Rast_lookup_d_colors().
  869. - Rast_lookup_c_colors()
  870. - Rast_lookup_f_colors()
  871. Converts the floating-point values in the float data array to their
  872. <em>r,g,b</em> color components. Embedded NULL-values are handled
  873. properly as well.
  874. - Rast_lookup_d_colors()
  875. Converts the floating-point values in the double data array to their
  876. <em>r,g,b</em> color components. Embedded NULL-values are handled
  877. properly as well.
  878. - Rast_add_color_rule()
  879. If raster type is CELL_TYPE, calls Rast_add_c_color_rule(), if
  880. FCELL_TYPE, calls Rast_add_f_color_rule(), and for DCELL_TYPE
  881. calls Rast_add_d_color_rule().
  882. - Rast_get_color()
  883. Looks up the rgb colors for the value in the color table.
  884. - Rast_mark_colors_as_fp()
  885. Sets a flag in the <em>colors</em> structure that indicates that these
  886. colors should only be looked up using floating-point raster data (not
  887. integer data).
  888. \section New_functions_to_support_a_colors_for_the_NULL_value New functions to support a color for the NULL-value
  889. - Rast_set_null_value_color()
  890. Sets the color (in <em>colors</em>) for the NULL-value to <em>r,g,b</em>.
  891. - Rast_get_null_value_color()
  892. Puts the red, green, and blue components of the color for the
  893. NULL-value into <em>r,g,b</em>.
  894. \section New_functions_to_support_a_default_color New functions to support a default color
  895. - Rast_set_default_color()
  896. Sets the default color (in <em>colors</em>) to <em>r,g,b</em>. This is
  897. the color for values which do not have an explicit rule.
  898. - Rast_get_default_color()
  899. Puts the red, green, and blue components of the <tt>"default"</tt>
  900. color into <em>r,g,b</em>.
  901. \section New_functions_to_support_treating_a_raster_layer_as_a_color_image New functions to support treating a raster layer as a color image
  902. - Rast_get_row_colors()
  903. Reads a row of raster data and converts it to red, green and blue
  904. components according to the colors.
  905. This provides a convenient way to treat a raster layer as a color
  906. image without having to explictly cater for each of CELL, FCELL and
  907. DCELL types.
  908. \section Upgraded_color_functions Upgraded color functions
  909. - Rast_read_colors()
  910. This routine reads the rules from the color file. If the input raster
  911. map is is a floating-point map (FCELL or DCELL) it calls
  912. Rast_mark_colors_as_fp().
  913. - Rast_write_colors()
  914. The rules are written out using floating-point format, removing
  915. trailing zeros (possibly producing integers). The flag marking the
  916. colors as floating-point is <b>not</b> written.
  917. - Rast_get_colors_min_max()
  918. If the color table is marked as <tt>"float"</tt>, then return the
  919. minimum as -(255&#94;3 * 128) and the maximum as (255&#94;3 *
  920. 128). This is to simulate a very <em>large</em> range so that GRASS
  921. doesn't attempt to use <em>colormode float</em> to allow interactive
  922. toggling of colors.
  923. - Rast_lookup_colors()
  924. Modified to return a color for NULL-values.
  925. - Rast_get_color()
  926. Modified to return a color for the NULL-value.
  927. \section Changes_to_the_Colors_structure Changes to the <TT>Colors</TT> structure
  928. Modifications to the Colors structure to support colors for
  929. floating-point data and the NULL-value consist of
  930. - the _Color_Rule_ struct was changed to have DCELL value (instead of
  931. CELL cat) to have the range be floating-point values instead of
  932. integer cats.
  933. - a color for NULL was added
  934. - the special color for zero was eliminated
  935. - a default color for values which have no assigned color was added
  936. - a flag was added to the Colors structure to indicate if either the
  937. map itself is floating-point (If the map is integer and the floating
  938. point functions are used to lookup colors, the values are checked to
  939. see if they are integer, and if they are, the integer mechanism is
  940. used)
  941. - fp_lookup - a lookup table for floating point numbers is added. It
  942. orders the end points of fp intervals into array with a pointer to a
  943. color rule for each inteval, and the binary search is then used when
  944. looking up colors instead of linearly searching through all color
  945. rules.
  946. \section Changes_to_the_colr_file Changes to the <TT>colr</TT> file
  947. - The rules are written out using floating-point format, removing trailing zeros (possibly producing integers) . For example, to ramp from red to green for the range [1.3,5.0]:
  948. \verbatim
  949. 1.3:255:0:0 5:0:255:0
  950. \endverbatim
  951. - The NULL-value color is written as:
  952. \verbatim
  953. nv:red:grn:blu
  954. \endverbatim
  955. - The default color (for values that don't have an explicit rule) is written
  956. as:
  957. \verbatim
  958. *:red:grn:blu
  959. \endverbatim
  960. \section Range_functions Range functions (new and upgraded)
  961. \subsection Modified_range_functions Modified range functions
  962. - Rast_read_range()
  963. Old range file (those with 4 numbers) should treat zeros in this file
  964. as NULL-values. New range files (those with just 2 numbers) should
  965. treat these numbers as real data (zeros are real data in this case).
  966. An empty range file indicates that the min, max are undefined. This is
  967. a valid case, and the result should be an initialized range struct
  968. with no defined min/max.
  969. If the range file is missing and the map is a floating-point map, this
  970. function will create a default range by calling
  971. Rast_construct_default_range().
  972. - Rast_init_range()
  973. Must set a flag in the range structure that indicates that no min/max
  974. have been defined - probably a "first" boolean flag.
  975. - Rast_update_range()
  976. NULL-values must be detected and ignored.
  977. - Rast_get_range_min_max()
  978. If the range structure has no defined min/max (first!=0) there will
  979. not be a valid range. In this case the min and max returned must be
  980. the NULL-value.
  981. - Rast_write_range()
  982. This routine only writes 2 numbers (min,max) to the range file,
  983. instead of the 4 (pmin,pmax,nmin,nmax) previously written. If there is
  984. no defined min,max, an empty file is written.
  985. \section New_range_functions New range functions
  986. - Rast_construct_default_range()
  987. Sets the integer range to [1,255].
  988. - Rast_read_range()
  989. If raster type is CELL_TYPE, calls Rast_read_range(), otherwise calls
  990. Rast_read_fp_range().
  991. - Rast_read_fp_range()
  992. Read the floating point range file <tt>f_range</tt>. This file is
  993. written in binary using XDR format. If there is no defined min/max in
  994. FPRange structure, an empty <tt>f_range</tt> file is created.
  995. An empty range file indicates that the min, max are undefined. This is
  996. a valid case, and the result should be an initialized range struct
  997. with no defined min/max.
  998. If the range file is missing and the map is a floating-point map, this
  999. function will create a default range by calling
  1000. Rast_construct_default_range().
  1001. - Rast_init_range()
  1002. If raster type is CELL_TYPE, calls Rast_init_range(), otherwise calls
  1003. Rast_init_fp_range().
  1004. - Rast_init_fp_range()
  1005. Must set a flag in the range structure that indicates that no min/max
  1006. have been defined - probably a "first" boolean flag.
  1007. - Rast_update_f_range()
  1008. - Rast_update_d_range()
  1009. Updates the floating-point range from the values in NULL-values must
  1010. be detected and ignored.
  1011. - Rast_get_fp_range_min_max()
  1012. Extract the min/max from the FPRange structure. If the range structure
  1013. has no defined min/max (first!=0) there will not be a valid range. In
  1014. this case the min and max returned must be the NULL-value.
  1015. - Rast_write_fp_range()
  1016. Write the floating point range file <tt>f_range</tt>. This file is
  1017. written in binary using XDR format. If there is no defined min/max in
  1018. <EM>r</EM>, an empty <tt>f_range</tt> file is created.
  1019. \section New_and_Upgraded_Cell_stats_functions New and Upgraded Cell_stats functions
  1020. Modified Cell_stats functions to handle NULL-values:
  1021. - Rast_init_cell_stats()
  1022. Set the count for NULL-values to zero.
  1023. - Rast_update_cell_stats()
  1024. Look for NULLs and update the NULL-value count.
  1025. - Rast_next_cell_stat()
  1026. Do not return a record for the NULL-value.
  1027. - Rast_find_cell_stat()
  1028. Allow finding the count for the NULL-value.
  1029. - Rast_get_stats_for_null_value()
  1030. Get a number of null values from stats structure. Note: when reporting
  1031. values which appear in a map using Rast_next_cell_stats() , to get stats
  1032. for null, call Rast_get_stats_for_null_value() first, since
  1033. Rast_next_cell_stats() does not report stats for null.
  1034. \section New_Quantization_Functions New Quantization Functions
  1035. New functions to support quantization of floating-point to integer:
  1036. - Rast_write_quant()
  1037. Writes the <tt>f_quant</tt> file for the raster map. If
  1038. mapset==Rast_mapset() i.e. the map is in current mapset, then the
  1039. original quant file in <tt>cell_misc/map/f_quant</tt> is
  1040. written. Othewise is written into <tt>quant2/mapset/name</tt> (much
  1041. like colr2 element). This results in map&#64;mapset being read using
  1042. quant rules stored Rast_mapset(). See Rast_read_quant() for detailes.
  1043. - Rast_set_quant_rules()
  1044. Sets quant translation rules for raster map opened for reading. After
  1045. calling this function, Rast_get_c_row() and Rast_get_row() will
  1046. use defined rules (instead of using rules defined in map's quant file)
  1047. to convert floats to ints.
  1048. - Rast_read_quant()
  1049. Reads quantization rules for raster map and stores them in the
  1050. quantization structure. If the map is in another mapset, first checks
  1051. for quant2 table for this map in current mapset.
  1052. - Rast_quant_init()
  1053. Initializes the Quant struct.
  1054. - Rast_quant_free()
  1055. Frees any memory allocated in Quant structure and re-initializes the
  1056. structure by calling Rast_quant_init().
  1057. - Rast_quant_truncate()
  1058. Sets the quant rules to perform simple truncation on floats.
  1059. - Rast_quant_truncate()
  1060. Sets the quant rules to perform simple rounding on floats.
  1061. - Rast_quant_organize_fp_lookup()
  1062. Organizes fp_lookup table for faster (logarithmic) lookup time
  1063. Rast_quant_organize_fp_lookup() creates a list of min and max for each
  1064. quant rule, sorts this list, and stores the pointer to quant rule that
  1065. should be used inbetween any 2 numbers in this list Also it stores
  1066. extreme points for 2 infinite rules, if exist After the call to
  1067. Rast_quant_organize_fp_lookup() instead of linearly searching through
  1068. list of rules to find a rule to apply, quant lookup will perform a
  1069. binary search to find an interval containing floating point value, and
  1070. then use the rule associated with this interval. When the value
  1071. doesn't fall within any interval, check for the infinite rules.
  1072. - Rast_quant_add_rule()
  1073. Add the rule that the floating-point range produces an integer in the
  1074. range by linear interpolation. Rules that are added later have higher
  1075. precedence when searching. If any of of the values is the NULL-value,
  1076. this rule is not added and 0 is returned. Otherwise return 1. if the
  1077. fp_lookup is organized, destroy it.
  1078. - Rast_quant_set_positive_infinite_rule()
  1079. - Rast_quant_get_positive_infinite_rule()
  1080. This rule has lower precedence than rules added with Rast_quant_add_rule().
  1081. - Rast_quant_set_negative_infinite_rule()
  1082. This rule has lower precedence than rules added with Rast_quant_add_rule().
  1083. - Rast_quant_get_negative_infinite_rule()
  1084. - Rast_quant_get_limits()
  1085. Extracts the minimum and maximum floating-point and integer values
  1086. from all the rules.
  1087. - Rast_quant_nrules()
  1088. Returns the number of rules, excluding the negative and positive
  1089. "infinite" rules.
  1090. - Rast_quant_get_rule()
  1091. The order of the rules returned by increasing <i>n</i> is the order
  1092. in which the rules are applied when quantizing a value - the first
  1093. rule applicable is used.
  1094. - Rast_quant_get_cell_value()
  1095. - Rast_quant_perform_d()
  1096. - Rast_quant_perform_f()
  1097. These next two functions are convenience functions to allow applications to
  1098. easily create quantization rules other than the defaults:
  1099. - Rast_quantize_fp_map()
  1100. Writes the <tt>f_quant</tt> file for the raster map.
  1101. - Rast_quantize_fp_map_range()
  1102. Writes the <tt>f_quant</TT> file for the raster map with one rule.
  1103. \section Categories_Labeling_Functions Categories Labeling Functions (new and upgraded)
  1104. \subsection Upgraded_Categories_structure Upgraded Categories structure
  1105. All the new programs which are using Categories structure directly
  1106. have to be modified to use API functions to update and retrieve info
  1107. from Categories structure. Both new and old API function can be used,
  1108. since old functions still have exact same functionality (even though
  1109. internally they are implemented very differently). New function names
  1110. end with raster_cats(); old function names end with _cats().
  1111. We made sure that all old fields in Categories structure are either
  1112. missing in new Categories structure or have exactly the same
  1113. meaning. We did it so that the modules using Categories structure
  1114. directly either do not compile with new gis library or work exactly
  1115. the same as bnefore. A programmer might want to read the data in a
  1116. floating point map in a way that each cell value stores index of it's
  1117. category label and data range. The way to do it is to call
  1118. Rast_set_quant_rules() after openning the map.
  1119. This is helpful when trying to collect statistics (how many cells of
  1120. each category are in the map. (although there is another new mechanism
  1121. to collect such stats - see Rast_mark_cats()) . Another reason to
  1122. get a category index instead of fp values is that this index will be
  1123. the FID into GRASS-DBMS link. Also he can use Rast_get_ith_cat()
  1124. to get the category information for each cell using this index.
  1125. Here is the new Categories structure defined in gis.h:
  1126. \code
  1127. struct Categories
  1128. {
  1129. CELL ncats ; /* total number of categories */
  1130. CELL num ; /* the highest cell values. Only exists
  1131. for backwards compatibility = (CELL)
  1132. max_fp_values in quant rules */
  1133. char *title ; /* name of data layer */
  1134. char *fmt ; /* printf-like format to generate labels */
  1135. float m1 ; /* Multiplication coefficient 1 */
  1136. float a1 ; /* Addition coefficient 1 */
  1137. float m2 ; /* Multiplication coefficient 2 */
  1138. float a2 ; /* Addition coefficient 2 */
  1139. struct Quant q ; /* rules mapping cell values to index in
  1140. list of labels */
  1141. char **labels ; /* array of labels of size num */
  1142. int * marks ; /* was the value with this label was used? */
  1143. int nalloc;
  1144. int last_marked_rule ;
  1145. } ;
  1146. \endcode
  1147. \section Changes_to_the_cats_file Changes to the <TT>cats</TT> file
  1148. The format of explicit label entries is the same for integer maps.
  1149. \verbatim
  1150. cat:description
  1151. \endverbatim
  1152. In addition label entries of new format is supported for floating point maps.
  1153. \verbatim
  1154. val:descr (where val is a floating point number)
  1155. \endverbatim
  1156. or
  1157. \verbatim
  1158. val1:val2:descr (where val1, val2 is a floating point range)
  1159. \endverbatim
  1160. Internally the labels are stored for fp ranges of data. However when
  1161. the cats file is written, all the decimal zeros are stripped so that
  1162. integer values appear as integers in the file. Also if values are the
  1163. same, only 1 value is written (i.e. first format).
  1164. This way even though the old cats files will be processed differently
  1165. internally, the user or application programmer will not notice this
  1166. difference as long as the proper api is used and the elements of
  1167. Categories structure are not accessed directly without API calls.
  1168. \section Range_functions Range functions (new and upgraded)
  1169. \section New_Functions_to_read_write_access_and_modify_Categories_structure New Functions to read/write access and modify Categories structure
  1170. - Rast_read_cats()
  1171. Is the same as existing Rast_read_cats().
  1172. - Rast_copy_cats()
  1173. - Rast_get_cat()
  1174. - Rast_get_c_cat()
  1175. - Rast_get_f_cat()
  1176. - Rast_get_d_cat()
  1177. Returns pointer to a string describing category.
  1178. - Rast_set_cat()
  1179. - Rast_set_c_cat()
  1180. - Rast_set_f_cat()
  1181. - Rast_set_d_cat()
  1182. Adds the label for range in category structure.
  1183. - Rast_number_of_cats()
  1184. Returns the number of labels. DO NOT use Rast_number_of_cats() (it
  1185. returns max cat number).
  1186. - Rast_get_ith_cat()
  1187. - Rast_get_ith_c_cat()
  1188. - Rast_get_ith_f_cat()
  1189. - Rast_get_ith_d_cat()
  1190. Returns i-th description and i-th data range from the list of category
  1191. descriptions with corresponding data ranges.
  1192. - Rast_get_cats_title()
  1193. Returns pointer to a string with title.
  1194. - Rast_unmark_cats()
  1195. Sets marks for all categories to 0. This initializes Categories
  1196. structure for subsequest calls to Rast_mark_cats () for each row
  1197. of data, where non-zero mark for i-th label means that some of the
  1198. cells in rast_row are labeled with i-th label and fall into i-th data
  1199. range.
  1200. These marks help determine from the Categories structure which labels
  1201. were used and which weren't.
  1202. - Rast_get_next_marked_cat()
  1203. - Rast_get_next_marked_c_cat()
  1204. - Rast_get_next_marked_f_cat()
  1205. - Rast_get_next_marked_d_cat()
  1206. Finds the next label and corresponding data range in the list of
  1207. marked categories. The category (label + data range) is marked by
  1208. Rast_mark_cats(). End points of the data range are converted to
  1209. raster type and returned. The number of times value from i-th
  1210. cat. data range appeared so far is returned in stats. See
  1211. Rast_unmark_cats(), Rast_rewind_cats() and Rast_mark_cats
  1212. ().
  1213. - Rast_mark_cats()
  1214. - Rast_mark_c_cats()
  1215. - Rast_mark_f_cats()
  1216. - Rast_mark_d_cats()
  1217. Looks up the category label for each raster value in the raster row
  1218. (row of raster cell value) and updates the marks for labels found.
  1219. Note: non-zero mark for i-th label stores the number of of raster
  1220. cells read so far which are labeled with i-th label and fall into i-th
  1221. data range.
  1222. - Rast_rewind_cats()
  1223. After call to this function Rast_get_next_marked_cat() returns the
  1224. first marked cat label.
  1225. - Rast_init_cats()
  1226. Same as existing Rast_init_cats() only ncats argument is
  1227. missign. ncats has no meaning in new Categories structure and only
  1228. stores (int) largets data value for backwards compatibility.
  1229. - Rast_set_cats_fmt()
  1230. Same as existing Rast_set_cats_fmt().
  1231. - Rast_set_cats_title()
  1232. Same as existing Rast_set_cats_title().
  1233. - Rast_write_cats()
  1234. Same as existing Rast_write_cats().
  1235. - Rast_free_cats()
  1236. Same as existing Rast_free_cats().
  1237. \section Library_Functions_that_are_Deprecated Library Functions that are Deprecated
  1238. These functions are deprecated, since they imply that the application
  1239. that uses them has not been upgraded to handle NULL-values and should
  1240. be eliminated from GRASS code.
  1241. - Rast_get_row()
  1242. To be replaced by Rast_get_c_row().
  1243. - Rast_get_row_nomask()
  1244. To be replaced by Rast_get_c_row_nomask().
  1245. - Rast_put_row()
  1246. To be replaced by Rast_put_c_row().
  1247. These functions are deprecated, since they can not be upgraded to
  1248. support NULL-values, and should be eliminated from GRASS code.
  1249. - Rast_open_map_new_random()
  1250. - Rast_put_row_random()
  1251. <b>Also, no support for random writing of floating-point rasters will be provided.</b>
  1252. \section Guidelines_for_upgrading_GRASS_4_x_Modules Guidelines for upgrading GRASS 4.x Modules
  1253. - Modules that process raster maps as <em>continuous</em> data should
  1254. read raster maps as floating-point. Modules that process raster maps
  1255. as <em>nominal</em> data should read raster maps as integer.
  1256. <em>Exception:</em> Modules that process raster colors or the modules
  1257. which report on raster categories labels should either always read the
  1258. maps as floating-point, or read the maps as integer if the map is
  1259. integer and floating-point if the map is floating-point.
  1260. - The quantization of floating-point to integer should NOT change the
  1261. color table. The color lookup should have its own separate
  1262. quantization.
  1263. - The quantization of floating-point to integer should NOT change the
  1264. Categories table. The Categories structure should have its own
  1265. separate quantization.
  1266. - Modules that read or write floating-point raster maps should use
  1267. <tt>double</tt> (<tt>DCELL</tt>) arrays instead of <tt>float</tt>
  1268. (<tt>FCELL</tt>) arrays.
  1269. - Modues should process NULL values in a well defined (consistent)
  1270. manner. Modules that processed zero as the pseudo NULL-value should
  1271. be changed to use the true NULL-value for this and process zero as
  1272. normal value.
  1273. - Modules should process non-NULL values as normal numbers and not
  1274. treat any particular numbers (e.g. zero) as special.
  1275. \section Important_hints_for_upgrades_to_modules Important hints for upgrades to raster modules
  1276. In general modules that use Rast_get_row(). Should use
  1277. Rast_get_c_row() instead.
  1278. Modules that use Rast_put_row(). Should use Rast_put_c_row()
  1279. instead.
  1280. \section Loading_the_Raster_Library Loading the Raster Library
  1281. The library is loaded by specifying
  1282. \verbatim
  1283. $(RASTERLIB)
  1284. \endverbatim
  1285. in the <tt>Makefile</tt>.
  1286. \section listOfFunctios List of functions
  1287. <b>TODO: Reorder functions</b>
  1288. \subsection MemoryAllocation Memory allocation
  1289. - Rast_allocate_c_buf()
  1290. - Rast_allocate_f_buf()
  1291. - Rast_allocate_d_buf()
  1292. - Rast_allocate_null_buf()
  1293. TODO: used in r.null and r.support, why Rast__ and not Rast_?
  1294. - Rast__allocate_null_bits()
  1295. - Rast__null_bitstream_size()
  1296. \subsection RasterMask Raster Mask
  1297. - Rast_suppress_masking()
  1298. - Rast_unsuppress_masking()
  1299. \subsection RasterStatistics Raster statistics
  1300. - Rast_cell_size()
  1301. - Rast_init_cell_stats()
  1302. - Rast_update_cell_stats()
  1303. - Rast_find_cell_stat()
  1304. - Rast_rewind_cell_stats()
  1305. - Rast_next_cell_stat()
  1306. - Rast_get_stats_for_null_value()
  1307. - Rast_free_cell_stats()
  1308. - Rast_cell_stats_histo_eq()
  1309. - Rast_get_cell_title()
  1310. - Rast_cell_stats_histo_eq()
  1311. \subsection RasterCategories Raster category management
  1312. - Rast_read_cats()
  1313. - Rast_get_max_cat()
  1314. - Rast_get_cats_title()
  1315. - Rast_get_c_cat()
  1316. - Rast_get_f_cat()
  1317. - Rast_get_d_cat()
  1318. - Rast_get_cat()
  1319. - Rast_unmark_cats()
  1320. - Rast_mark_c_cats()
  1321. - Rast_mark_f_cats()
  1322. - Rast_mark_d_cats()
  1323. - Rast_mark_cats()
  1324. - Rast_rewind_cats()
  1325. - Rast_get_next_marked_d_cat()
  1326. - Rast_get_next_marked_f_cat()
  1327. - Rast_get_next_marked_c_cat()
  1328. - Rast_get_next_marked_cat()
  1329. - Rast_set_c_cat()
  1330. - Rast_set_f_cat()
  1331. - Rast_set_d_cat()
  1332. - Rast_write_cats()
  1333. - Rast_get_ith_d_cat()
  1334. - Rast_get_ith_f_cat()
  1335. - Rast_get_ith_c_cat()
  1336. - Rast_get_ith_cat()
  1337. - Rast_init_cats()
  1338. - Rast_set_cats_title()
  1339. - Rast_set_cats_fmt()
  1340. - Rast_free_cats()
  1341. - Rast_copy_cats()
  1342. - Rast_number_of_cats()
  1343. - Rast_sort_cats()
  1344. \subsection RasterFileManagement Raster file management
  1345. - Rast_close()
  1346. - Rast_unopen()
  1347. \subsection ColorFunctions Color functions
  1348. - Rast_make_ryg_colors()
  1349. - Rast_make_ryg_fp_colors()
  1350. - Rast_make_aspect_colors()
  1351. - Rast_make_aspect_fp_colors()
  1352. - Rast_make_byr_colors()
  1353. - Rast_make_byr_fp_colors()
  1354. - Rast_make_bgyr_colors()
  1355. - Rast_make_bgyr_fp_colors()
  1356. - Rast_make_byg_colors()
  1357. - Rast_make_byg_fp_colors()
  1358. - Rast_make_grey_scale_colors()
  1359. - Rast_make_grey_scale_fp_colors()
  1360. - Rast_make_gyr_colors()
  1361. - Rast_make_gyr_fp_colors()
  1362. - Rast_make_rainbow_colors()
  1363. - Rast_make_rainbow_fp_colors()
  1364. - Rast_make_ramp_colors()
  1365. - Rast_make_ramp_fp_colors()
  1366. - Rast_make_wave_colors()
  1367. - Rast_make_wave_fp_colors()
  1368. - Rast_free_colors()
  1369. - Rast_get_color()
  1370. - Rast_get_c_color()
  1371. - Rast_get_f_color()
  1372. - Rast_get_d_color()
  1373. - Rast_get_null_value_color()
  1374. - Rast_get_default_color()
  1375. - Rast_make_histogram_eq_colors()
  1376. - Rast_make_histogram_log_colors()
  1377. - Rast_init_colors()
  1378. - Rast_invert_colors()
  1379. - Rast_lookup_c_colors()
  1380. - Rast_lookup_f_colors()
  1381. - Rast_lookup_d_colors()
  1382. - Rast_lookup_colors()
  1383. - Rast_make_random_colors()
  1384. - Rast_set_c_color_range()
  1385. - Rast_set_d_color_range()
  1386. - Rast_get_c_color_range()
  1387. - Rast_get_d_color_range()
  1388. - Rast_read_colors()
  1389. - Rast_mark_colors_as_fp()
  1390. - Rast_remove_colors()
  1391. - Rast_add_d_color_rule()
  1392. - Rast_add_f_color_rule()
  1393. - Rast_add_c_color_rule()
  1394. - Rast_add_color_rule()
  1395. - Rast_add_modular_d_color_rule()
  1396. - Rast_add_modular_f_color_rule()
  1397. - Rast_add_modular_c_color_rule()
  1398. - Rast_add_modular_color_rule()
  1399. - Rast_colors_count()
  1400. - Rast_get_fp_color_rule()
  1401. - Rast_parse_color_rule()
  1402. - Rast_parse_color_rule_error()
  1403. - Rast_read_color_rule()
  1404. - Rast_read_color_rules()
  1405. - Rast_load_colors()
  1406. - Rast_load_fp_colors()
  1407. - Rast_make_colors()
  1408. - Rast_make_fp_colors()
  1409. - Rast_set_c_color()
  1410. - Rast_set_d_color()
  1411. - Rast_set_null_value_color()
  1412. - Rast_set_default_color()
  1413. - Rast_shift_c_colors()
  1414. - Rast_shift_d_colors()
  1415. - Rast_write_colors()
  1416. \subsection RasterFloatingPointManagement Raster floating point management
  1417. - Rast_fpreclass_clear()
  1418. - Rast_fpreclass_reset()
  1419. - Rast_fpreclass_init()
  1420. - Rast_fpreclass_set_domain()
  1421. - Rast_fpreclass_set_range()
  1422. - Rast_fpreclass_get_limits()
  1423. - Rast_fpreclass_nof_rules()
  1424. - Rast_fpreclass_get_ith_rule()
  1425. - Rast_fpreclass_set_neg_infinite_rule()
  1426. - Rast_fpreclass_get_neg_infinite_rule()
  1427. - Rast_fpreclass_set_pos_infinite_rule()
  1428. - Rast_fpreclass_get_pos_infinite_rule()
  1429. - Rast_fpreclass_add_rule()
  1430. - Rast_fpreclass_reverse_rule_order()
  1431. - Rast_fpreclass_get_cell_value()
  1432. - Rast_fpreclass_perform_di()
  1433. - Rast_fpreclass_perform_df()
  1434. - Rast_fpreclass_perform_dd()
  1435. - Rast_fpreclass_perform_fi()
  1436. - Rast_fpreclass_perform_ff()
  1437. - Rast_fpreclass_perform_fd()
  1438. - Rast_fpreclass_perform_ii()
  1439. - Rast_fpreclass_perform_if()
  1440. - Rast_fpreclass_perform_id()
  1441. \subsection RasterMapReading Raster map reading
  1442. - Rast_get_cellhd()
  1443. - Rast_get_row_nomask()
  1444. - Rast_get_c_row_nomask()
  1445. - Rast_get_f_row_nomask()
  1446. - Rast_get_d_row_nomask()
  1447. - Rast_get_row()
  1448. - Rast_get_c_row()
  1449. - Rast_get_f_row()
  1450. - Rast_get_d_row()
  1451. - Rast_get_null_value_row()
  1452. - Rast_get_row_colors()
  1453. \subsection RasterMapHistogram Raster map histogram
  1454. - Rast_histogram_eq()
  1455. - Rast_init_histogram()
  1456. - Rast_read_histogram()
  1457. - Rast_write_histogram()
  1458. - Rast_write_histogram_cs()
  1459. - Rast_make_histogram_cs()
  1460. - Rast_get_histogram_num()
  1461. - Rast_get_histogram_cat()
  1462. - Rast_get_histogram_count()
  1463. - Rast_free_histogram()
  1464. - Rast_sort_histogram()
  1465. - Rast_sort_histogram_by_count()
  1466. - Rast_remove_histogram()
  1467. - Rast_add_histogram()
  1468. - Rast_set_histogram()
  1469. - Rast_extend_histogram()
  1470. - Rast_zero_histogram()
  1471. - Rast_want_histogram()
  1472. \subsection RasterMapHistory Raster map history
  1473. - Rast_read_history()
  1474. - Rast_write_history()
  1475. - Rast_short_history()
  1476. - Rast_command_history()
  1477. \subsection RasterMapInterpolation Raster map interpolation
  1478. - Rast_interp_linear()
  1479. - Rast_interp_bilinear()
  1480. - Rast_interp_cubic()
  1481. - Rast_interp_bicubic()
  1482. \subsection RasterMapQuantization Raster map quantization
  1483. - Rast_quant_clear()
  1484. - Rast_quant_free()
  1485. - Rast_quant_init()
  1486. - Rast_quant_is_truncate()
  1487. - Rast_quant_is_round()
  1488. - Rast_quant_truncate()
  1489. - Rast_quant_round()
  1490. - Rast_quant_get_limits()
  1491. - Rast_quant_nof_rules()
  1492. - Rast_quant_get_ith_rule()
  1493. - Rast_quant_set_neg_infinite_rule()
  1494. - Rast_quant_get_neg_infinite_rule()
  1495. - Rast_quant_set_pos_infinite_rule()
  1496. - Rast_quant_get_pos_infinite_rule()
  1497. - Rast_quant_add_rule()
  1498. - Rast_quant_reverse_rule_order()
  1499. - Rast_quant_get_cell_value()
  1500. - Rast_quant_perform_d()
  1501. - Rast_quant_perform_f()
  1502. - Rast_quantize_fp_map()
  1503. - Rast_quantize_fp_map_range()
  1504. - Rast_write_quant()
  1505. - Rast_read_quant()
  1506. \subsection ToDo yet unsorted functions
  1507. - Rast_maskfd()
  1508. - Rast_mask_info()
  1509. - Rast_set_null_value()
  1510. - Rast_set_c_null_value()
  1511. - Rast_set_f_null_value()
  1512. - Rast_set_d_null_value()
  1513. - Rast_is_null_value()
  1514. - Rast_is_c_null_value()
  1515. - Rast_is_f_null_value()
  1516. - Rast_is_d_null_value()
  1517. - Rast_insert_null_values()
  1518. - Rast_insert_c_null_values()
  1519. - Rast_insert_f_null_values()
  1520. - Rast_insert_d_null_values()
  1521. - Rast_open_old()
  1522. - Rast_open_c_new()
  1523. - Rast_open_c_new_uncompressed()
  1524. - Rast_set_cell_format()
  1525. - Rast_get_cell_format()
  1526. - Rast_open_fp_new()
  1527. - Rast_open_fp_new_uncompressed()
  1528. - Rast_set_fp_type()
  1529. - Rast_map_is_fp()
  1530. - Rast_map_type()
  1531. - Rast_get_map_type()
  1532. - Rast_open_new()
  1533. - Rast_open_new_uncompressed()
  1534. - Rast_set_quant_rules()
  1535. - Rast_put_cellhd()
  1536. - Rast_put_row()
  1537. - Rast_put_c_row()
  1538. - Rast_put_f_row()
  1539. - Rast_put_d_row()
  1540. - Rast_put_cell_title()
  1541. - Rast_truncate_fp_map()
  1542. - Rast_round_fp_map()
  1543. - Rast_construct_default_range()
  1544. - Rast_read_fp_range()
  1545. - Rast_read_range()
  1546. - Rast_write_range()
  1547. - Rast_write_fp_range()
  1548. - Rast_update_range()
  1549. - Rast_update_fp_range()
  1550. - Rast_row_update_range()
  1551. - Rast_row_update_fp_range()
  1552. - Rast_init_range()
  1553. - Rast_get_range_min_max()
  1554. - Rast_init_fp_range()
  1555. - Rast_get_fp_range_min_max()
  1556. - Rast_raster_cmp()
  1557. - Rast_raster_cpy()
  1558. - Rast_set_c_value()
  1559. - Rast_set_f_value()
  1560. - Rast_set_d_value()
  1561. - Rast_get_c_value()
  1562. - Rast_get_f_value()
  1563. - Rast_get_d_value()
  1564. - Rast_read_units()
  1565. - Rast_read_vdatum()
  1566. - Rast_write_units()
  1567. - Rast_write_vdatum()
  1568. - Rast_is_reclass()
  1569. - Rast_is_reclassed_to()
  1570. - Rast_get_reclass()
  1571. - Rast_free_reclass()
  1572. - Rast_put_reclass()
  1573. - Rast_get_sample_nearest()
  1574. - Rast_get_sample_bilinear()
  1575. - Rast_get_sample_cubic()
  1576. - Rast_get_sample()
  1577. - Rast_zero_c_buf()
  1578. - Rast_zero_buf()
  1579. */