GRASS GIS 7 Programmer's Manual  7.5.svn(2018)-r72996
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gdal.c
Go to the documentation of this file.
1 /*!
2  \file lib/raster/gdal.c
3 
4  \brief Raster Library - Utilization of GDAL library.
5 
6  (C) 2010 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Glynn Clements
12 */
13 
14 #include <stdlib.h>
15 #include <string.h>
16 #include <unistd.h>
17 
18 #include <grass/config.h>
19 #include <grass/gis.h>
20 #include <grass/raster.h>
21 #include <grass/gprojects.h>
22 #include <grass/glocale.h>
23 
24 #include "R.h"
25 
26 #ifndef HAVE_GDAL
27 #undef GDAL_LINK
28 #endif
29 
30 #ifdef GDAL_LINK
31 
32 #ifdef GDAL_DYNAMIC
33 # if defined(__unix) || defined(__unix__)
34 # include <dlfcn.h>
35 # endif
36 # ifdef _WIN32
37 # include <windows.h>
38 # endif
39 #endif
40 
41 static void CPL_STDCALL(*pGDALAllRegister) (void);
42 static void CPL_STDCALL(*pGDALClose) (GDALDatasetH);
43 static GDALRasterBandH CPL_STDCALL(*pGDALGetRasterBand) (GDALDatasetH, int);
44 static GDALDatasetH CPL_STDCALL(*pGDALOpen) (const char *pszFilename,
45  GDALAccess eAccess);
46 static CPLErr CPL_STDCALL(*pGDALRasterIO) (GDALRasterBandH hRBand,
47  GDALRWFlag eRWFlag, int nDSXOff,
48  int nDSYOff, int nDSXSize,
49  int nDSYSize, void *pBuffer,
50  int nBXSize, int nBYSize,
51  GDALDataType eBDataType,
52  int nPixelSpace, int nLineSpace);
53 static GDALDriverH CPL_STDCALL(*pGDALGetDriverByName) (const char *);
54 static const char *CPL_STDCALL(*pGDALGetMetadataItem) (GDALMajorObjectH,
55  const char *,
56  const char *);
57 static GDALDatasetH CPL_STDCALL(*pGDALCreate) (GDALDriverH hDriver,
58  const char *, int, int, int,
59  GDALDataType, char **);
60 static GDALDatasetH CPL_STDCALL(*pGDALCreateCopy) (GDALDriverH, const char *,
61  GDALDatasetH, int, char **,
62  GDALProgressFunc, void *);
63 static CPLErr CPL_STDCALL(*pGDALSetRasterNoDataValue) (GDALRasterBandH,
64  double);
65 static CPLErr CPL_STDCALL(*pGDALSetGeoTransform) (GDALDatasetH, double *);
66 static CPLErr CPL_STDCALL(*pGDALSetProjection) (GDALDatasetH, const char *);
67 static const char *CPL_STDCALL(*pGDALGetDriverShortName) (GDALDriverH);
68 static GDALDriverH CPL_STDCALL(*pGDALGetDatasetDriver) (GDALDatasetH);
69 
70 #if GDAL_DYNAMIC
71 # if defined(__unix) && !defined(__unix__)
72 # define __unix__ __unix
73 # endif
74 
75 static void *library_h;
76 
77 static void *get_symbol(const char *name)
78 {
79  void *sym;
80 
81 # ifdef __unix__
82  sym = dlsym(library_h, name);
83 # endif
84 # ifdef _WIN32
85  sym = GetProcAddress((HINSTANCE) library_h, name);
86 # endif
87 
88  if (!sym)
89  G_fatal_error(_("Unable to locate symbol <%s>"), name);
90 
91  return sym;
92 }
93 
94 static void try_load_library(const char *name)
95 {
96 # ifdef __unix__
97  library_h = dlopen(name, RTLD_NOW);
98 # endif
99 # ifdef _WIN32
100  library_h = LoadLibrary(name);
101 # endif
102 }
103 
104 static void load_library(void)
105 {
106  static const char *const candidates[] = {
107 # ifdef __unix__
108  "libgdal.so.20",
109  "libgdal.so.1",
110  "libgdal.1.1.so",
111  "gdal.1.0.so",
112  "gdal.so.1.0",
113  "libgdal.so",
114  "libgdal1.6.0.so",
115  "libgdal1.7.0.so",
116 # endif
117 # ifdef _WIN32
118  "gdal202.dll",
119  "gdal201.dll",
120  "gdal200.dll",
121  "gdal111.dll",
122  "gdal110.dll",
123  "gdal19.dll",
124  "gdal18.dll",
125  "gdal17.dll",
126  "gdal16.dll",
127  "gdal15.dll",
128  "gdal11.dll",
129  "gdal.1.0.dll",
130  "libgdal-1.dll",
131  "gdal.dll",
132 # endif
133  NULL
134  };
135  int i;
136 
137  for (i = 0; candidates[i]; i++) {
138  try_load_library(candidates[i]);
139  if (library_h) {
140  G_debug(3, "found %s", candidates[i]);
141  return;
142  }
143  }
144 
145  G_fatal_error(_("Unable to load GDAL library"));
146 }
147 
148 static void init_gdal(void)
149 {
150  load_library();
151 
152 # if defined(_WIN32) && !defined(_WIN64)
153  pGDALAllRegister = get_symbol("_GDALAllRegister@0");
154  pGDALOpen = get_symbol("_GDALOpen@8");
155  pGDALClose = get_symbol("_GDALClose@4");
156  pGDALGetRasterBand = get_symbol("_GDALGetRasterBand@8");
157  pGDALRasterIO = get_symbol("_GDALRasterIO@48");
158  pGDALGetDriverByName = get_symbol("_GDALGetDriverByName@4");
159  pGDALGetMetadataItem = get_symbol("_GDALGetMetadataItem@12");
160  pGDALCreate = get_symbol("_GDALCreate@28");
161  pGDALCreateCopy = get_symbol("_GDALCreateCopy@28");
162  pGDALSetRasterNoDataValue = get_symbol("_GDALSetRasterNoDataValue@12");
163  pGDALSetGeoTransform = get_symbol("_GDALSetGeoTransform@8");
164  pGDALSetProjection = get_symbol("_GDALSetProjection@8");
165  pGDALGetDriverShortName = get_symbol("_GDALGetDriverShortName@4");
166  pGDALGetDatasetDriver = get_symbol("_GDALGetDatasetDriver@4");
167 #else
168  pGDALAllRegister = get_symbol("GDALAllRegister");
169  pGDALOpen = get_symbol("GDALOpen");
170  pGDALClose = get_symbol("GDALClose");
171  pGDALGetRasterBand = get_symbol("GDALGetRasterBand");
172  pGDALRasterIO = get_symbol("GDALRasterIO");
173  pGDALGetDriverByName = get_symbol("GDALGetDriverByName");
174  pGDALGetMetadataItem = get_symbol("GDALGetMetadataItem");
175  pGDALCreate = get_symbol("GDALCreate");
176  pGDALCreateCopy = get_symbol("GDALCreateCopy");
177  pGDALSetRasterNoDataValue = get_symbol("GDALSetRasterNoDataValue");
178  pGDALSetGeoTransform = get_symbol("GDALSetGeoTransform");
179  pGDALSetProjection = get_symbol("GDALSetProjection");
180  pGDALGetDriverShortName = get_symbol("GDALGetDriverShortName");
181  pGDALGetDatasetDriver = get_symbol("GDALGetDatasetDriver");
182 #endif
183 }
184 
185 #else /* GDAL_DYNAMIC */
186 
187 static void init_gdal(void)
188 {
189  pGDALAllRegister = &GDALAllRegister;
190  pGDALOpen = &GDALOpen;
191  pGDALClose = &GDALClose;
192  pGDALGetRasterBand = &GDALGetRasterBand;
193  pGDALRasterIO = &GDALRasterIO;
194  pGDALGetDriverByName = &GDALGetDriverByName;
195  pGDALGetMetadataItem = &GDALGetMetadataItem;
196  pGDALCreate = &GDALCreate;
197  pGDALCreateCopy = &GDALCreateCopy;
198  pGDALSetRasterNoDataValue = &GDALSetRasterNoDataValue;
199  pGDALSetGeoTransform = &GDALSetGeoTransform;
200  pGDALSetProjection = &GDALSetProjection;
201  pGDALGetDriverShortName = &GDALGetDriverShortName;
202  pGDALGetDatasetDriver = &GDALGetDatasetDriver;
203 }
204 
205 #endif /* GDAL_DYNAMIC */
206 
207 #endif /* GDAL_LINK */
208 
209 /*!
210  \brief Initialization
211 
212  Register all GDAL drivers.
213 */
214 void Rast_init_gdal(void)
215 {
216 #ifdef GDAL_LINK
217  static int initialized;
218 
219  if (G_is_initialized(&initialized))
220  return;
221 
222  init_gdal();
223  (*pGDALAllRegister) ();
224  G_initialize_done(&initialized);
225 #endif
226 }
227 
228 /*!
229  \brief Get GDAL link settings for given raster map
230 
231  \param name map name
232  \param mapset name of mapset
233 
234  \return pointer to GDAL_link structure
235  \return NULL if link not found
236 */
237 struct GDAL_link *Rast_get_gdal_link(const char *name, const char *mapset)
238 {
239 #ifdef GDAL_LINK
240  GDALDatasetH data;
241  GDALRasterBandH band;
242  GDALDataType type;
243  RASTER_MAP_TYPE req_type;
244 #endif
245  const char *filename;
246  int band_num;
247  struct GDAL_link *gdal;
248  RASTER_MAP_TYPE map_type;
249  FILE *fp;
250  struct Key_Value *key_val;
251  const char *p;
252  DCELL null_val;
253  int hflip, vflip;
254 
255  if (!G_find_raster2(name, mapset))
256  return NULL;
257 
258  map_type = Rast_map_type(name, mapset);
259  if (map_type < 0)
260  return NULL;
261 
262  fp = G_fopen_old_misc("cell_misc", "gdal", name, mapset);
263  if (!fp)
264  return NULL;
265  key_val = G_fread_key_value(fp);
266  fclose(fp);
267 
268  if (!key_val)
269  return NULL;
270 
271  filename = G_find_key_value("file", key_val);
272  if (!filename)
273  return NULL;
274 
275  p = G_find_key_value("band", key_val);
276  if (!p)
277  return NULL;
278  band_num = atoi(p);
279  if (!band_num)
280  return NULL;
281 
282  p = G_find_key_value("null", key_val);
283  if (!p)
284  return NULL;
285  if (strcmp(p, "none") == 0)
286  Rast_set_d_null_value(&null_val, 1);
287  else
288  null_val = atof(p);
289 
290  hflip = G_find_key_value("hflip", key_val) ? 1 : 0;
291  vflip = G_find_key_value("vflip", key_val) ? 1 : 0;
292 
293 #ifdef GDAL_LINK
294  p = G_find_key_value("type", key_val);
295  if (!p)
296  return NULL;
297  type = atoi(p);
298 
299  switch (type) {
300  case GDT_Byte:
301  case GDT_Int16:
302  case GDT_UInt16:
303  case GDT_Int32:
304  case GDT_UInt32:
305  req_type = CELL_TYPE;
306  break;
307  case GDT_Float32:
308  req_type = FCELL_TYPE;
309  break;
310  case GDT_Float64:
311  req_type = DCELL_TYPE;
312  break;
313  default:
314  return NULL;
315  }
316 
317  if (req_type != map_type)
318  return NULL;
319 
320  Rast_init_gdal();
321 
322  data = (*pGDALOpen) (filename, GA_ReadOnly);
323  if (!data)
324  return NULL;
325 
326  band = (*pGDALGetRasterBand) (data, band_num);
327  if (!band) {
328  (*pGDALClose) (data);
329  return NULL;
330  }
331 #endif
332 
333  gdal = G_calloc(1, sizeof(struct GDAL_link));
334 
335  gdal->filename = G_store(filename);
336  gdal->band_num = band_num;
337  gdal->null_val = null_val;
338  gdal->hflip = hflip;
339  gdal->vflip = vflip;
340 #ifdef GDAL_LINK
341  gdal->data = data;
342  gdal->band = band;
343  gdal->type = type;
344 #endif
345 
346  return gdal;
347 }
348 
349 struct GDAL_Options
350 {
351  const char *dir;
352  const char *ext;
353  const char *format;
354  char **options;
355 };
356 
357 static struct state
358 {
359  int initialized;
360  struct GDAL_Options opts;
361  struct Key_Value *projinfo, *projunits, *projepsg;
362  char *srswkt;
363 } state;
364 
365 static struct state *st = &state;
366 
367 static void read_gdal_options(void)
368 {
369  FILE *fp;
370  struct Key_Value *key_val;
371  const char *p;
372 
373  fp = G_fopen_old("", "GDAL", G_mapset());
374  if (!fp)
375  G_fatal_error(_("Unable to open GDAL file"));
376  key_val = G_fread_key_value(fp);
377  fclose(fp);
378 
379  p = G_find_key_value("directory", key_val);
380  if (!p)
381  p = "gdal";
382  if (*p == '/') {
383  st->opts.dir = G_store(p);
384  }
385  else {
386  char path[GPATH_MAX];
387 
388  G_file_name(path, p, "", G_mapset());
389  st->opts.dir = G_store(path);
390  if (access(path, 0) != 0)
392  }
393 
394  p = G_find_key_value("extension", key_val);
395  st->opts.ext = G_store(p ? p : "");
396 
397  p = G_find_key_value("format", key_val);
398  st->opts.format = G_store(p ? p : "GTiff");
399 
400  p = G_find_key_value("options", key_val);
401  st->opts.options = p ? G_tokenize(p, ",") : NULL;
402 
403  G_free_key_value(key_val);
404 }
405 
406 /*!
407  \brief Create GDAL settings for given raster map
408 
409  \param name map name
410  \param map_type map type (CELL, FCELL, DCELL)
411 
412  \return pointer to allocated GDAL_link structure
413  \return NULL on error
414 */
415 struct GDAL_link *Rast_create_gdal_link(const char *name,
416  RASTER_MAP_TYPE map_type)
417 {
418 #ifdef GDAL_LINK
419  char path[GPATH_MAX];
420  GDALDriverH driver;
421  double transform[6];
422  struct GDAL_link *gdal;
423  FILE *fp;
424  struct Key_Value *key_val;
425  char buf[32];
426 
428 
429  Rast_init_gdal();
430 
431  if (!G_is_initialized(&st->initialized)) {
432  read_gdal_options();
433  st->projinfo = G_get_projinfo();
434  st->projunits = G_get_projunits();
435  st->projepsg = G_get_projepsg();
436  if (st->projinfo && st->projunits)
437  st->srswkt = GPJ_grass_to_wkt2(st->projinfo, st->projunits,
438  st->projepsg, 0, 0);
439  G_initialize_done(&st->initialized);
440  }
441 
442  gdal = G_calloc(1, sizeof(struct GDAL_link));
443 
444  sprintf(path, "%s/%s%s", st->opts.dir, name, st->opts.ext);
445  gdal->filename = G_store(path);
446  gdal->band_num = 1;
447  gdal->hflip = 0;
448  gdal->vflip = 0;
449 
450  switch (map_type) {
451  case CELL_TYPE:
452  switch (R__.nbytes) {
453  case 1:
454  gdal->type = GDT_Byte;
455  gdal->null_val = (DCELL) 0xFF;
456  break;
457  case 2:
458  gdal->type = GDT_UInt16;
459  gdal->null_val = (DCELL) 0xFFFF;
460  break;
461  case 3:
462  case 4:
463  gdal->type = GDT_Int32;
464  gdal->null_val = (DCELL) 0x80000000U;
465  break;
466  }
467  break;
468  case FCELL_TYPE:
469  gdal->type = GDT_Float32;
470  Rast_set_d_null_value(&gdal->null_val, 1);
471  break;
472  case DCELL_TYPE:
473  gdal->type = GDT_Float64;
474  Rast_set_d_null_value(&gdal->null_val, 1);
475  break;
476  default:
477  G_fatal_error(_("Invalid map type <%d>"), map_type);
478  break;
479  }
480 
481  driver = (*pGDALGetDriverByName) (st->opts.format);
482  if (!driver)
483  G_fatal_error(_("Unable to get <%s> driver"), st->opts.format);
484 
485  /* Does driver support GDALCreate ? */
486  if ((*pGDALGetMetadataItem) (driver, GDAL_DCAP_CREATE, NULL)) {
487  gdal->data =
488  (*pGDALCreate)(driver, gdal->filename,
490  1, gdal->type, st->opts.options);
491  if (!gdal->data)
492  G_fatal_error(_("Unable to create <%s> dataset using <%s> driver"),
493  name, st->opts.format);
494  }
495  /* If not - create MEM driver for intermediate dataset.
496  * Check if raster can be created at all (with GDALCreateCopy) */
497  else if ((*pGDALGetMetadataItem) (driver, GDAL_DCAP_CREATECOPY, NULL)) {
498  GDALDriverH mem_driver;
499 
500  G_message(_("Driver <%s> does not support direct writing. "
501  "Using MEM driver for intermediate dataset."),
502  st->opts.format);
503 
504  mem_driver = (*pGDALGetDriverByName) ("MEM");
505  if (!mem_driver)
506  G_fatal_error(_("Unable to get in-memory raster driver"));
507 
508  gdal->data =
509  (*pGDALCreate)(mem_driver, "",
511  1, gdal->type, st->opts.options);
512  if (!gdal->data)
513  G_fatal_error(_("Unable to create <%s> dataset using memory driver"),
514  name);
515  }
516  else
517  G_fatal_error(_("Driver <%s> does not support creating rasters"),
518  st->opts.format);
519 
520  gdal->band = (*pGDALGetRasterBand) (gdal->data, gdal->band_num);
521 
522  (*pGDALSetRasterNoDataValue) (gdal->band, gdal->null_val);
523 
524  /* Set Geo Transform */
525  transform[0] = R__.wr_window.west;
526  transform[1] = R__.wr_window.ew_res;
527  transform[2] = 0.0;
528  transform[3] = R__.wr_window.north;
529  transform[4] = 0.0;
530  transform[5] = -R__.wr_window.ns_res;
531 
532  if ((*pGDALSetGeoTransform) (gdal->data, transform) >= CE_Failure)
533  G_warning(_("Unable to set geo transform"));
534 
535  if (st->srswkt)
536  if ((*pGDALSetProjection) (gdal->data, st->srswkt) == CE_Failure)
537  G_warning(_("Unable to set projection"));
538 
539  fp = G_fopen_new_misc("cell_misc", "gdal", name);
540  if (!fp)
541  G_fatal_error(_("Unable to create cell_misc/%s/gdal file"), name);
542 
543  key_val = G_create_key_value();
544 
545  G_set_key_value("file", gdal->filename, key_val);
546 
547  sprintf(buf, "%d", gdal->band_num);
548  G_set_key_value("band", buf, key_val);
549 
550  sprintf(buf, "%.22g", gdal->null_val);
551  G_set_key_value("null", buf, key_val);
552 
553  sprintf(buf, "%d", gdal->type);
554  G_set_key_value("type", buf, key_val);
555 
556  if (G_fwrite_key_value(fp, key_val) < 0)
557  G_fatal_error(_("Error writing cell_misc/%s/gdal file"), name);
558 
559  G_free_key_value(key_val);
560 
561  fclose(fp);
562 
563  return gdal;
564 #else
565  return NULL;
566 #endif
567 }
568 
569 /*!
570  \brief Close existing GDAL link
571 
572  \param gdal pointer to GDAL_link to be closed
573 */
574 void Rast_close_gdal_link(struct GDAL_link *gdal)
575 {
576 #ifdef GDAL_LINK
577  (*pGDALClose) (gdal->data);
578 #endif
579  G_free(gdal->filename);
580  G_free(gdal);
581 }
582 
583 /*!
584  \brief Close existing GDAL link and write out data
585 
586  \param gdal pointer to GDAL_link to be closed
587 
588  \return 1 on success
589  \return -1 on failure
590 */
592 {
593  int stat = 1;
594 
595 #ifdef GDAL_LINK
596  GDALDriverH src_drv = (*pGDALGetDatasetDriver) (gdal->data);
597 
598  if (G_strcasecmp((*pGDALGetDriverShortName) (src_drv), "MEM") == 0) {
599  GDALDriverH dst_drv = (*pGDALGetDriverByName) (st->opts.format);
600  GDALDatasetH dst =
601  (*pGDALCreateCopy) (dst_drv, gdal->filename, gdal->data, FALSE,
602  st->opts.options, NULL, NULL);
603 
604  if (!dst) {
605  G_warning(_("Unable to create output file <%s> using driver <%s>"),
606  gdal->filename, st->opts.format);
607  stat = -1;
608  }
609  (*pGDALClose) (dst);
610  }
611 
612  (*pGDALClose) (gdal->data);
613 
614 #endif
615  G_free(gdal->filename);
616  G_free(gdal);
617 
618  return stat;
619 }
620 
621 #ifdef GDAL_LINK
622 /*!
623  \brief Input/output function for GDAL links
624 
625  See GDAL's RasterIO for details.
626 */
627 CPLErr Rast_gdal_raster_IO(GDALRasterBandH band, GDALRWFlag rw_flag,
628  int x_off, int y_off, int x_size, int y_size,
629  void *buffer, int buf_x_size, int buf_y_size,
630  GDALDataType buf_type, int pixel_size,
631  int line_size)
632 {
633  return (*pGDALRasterIO) (band, rw_flag, x_off, y_off, x_size, y_size,
634  buffer, buf_x_size, buf_y_size, buf_type,
635  pixel_size, line_size);
636 }
637 #endif
int G_make_mapset_element(const char *p_element)
Create element in the current mapset.
Definition: mapset_msc.c:38
#define CELL_TYPE
Definition: raster.h:11
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
Definition: strings.c:46
const char * G_find_key_value(const char *key, const struct Key_Value *kv)
Find given key (case sensitive)
Definition: key_value1.c:84
struct driver * driver
Definition: driver/init.c:25
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:149
Definition: R.h:88
struct Key_Value * G_get_projunits(void)
Gets units information for location.
Definition: get_projinfo.c:29
void Rast__init_window(void)
struct Key_Value * G_fread_key_value(FILE *fd)
Read key/values pairs from file.
Definition: key_value2.c:49
int Rast_close_gdal_write_link(struct GDAL_link *gdal)
Close existing GDAL link and write out data.
Definition: gdal.c:591
double west
Extent coordinates (west)
Definition: gis.h:442
double DCELL
Definition: gis.h:581
char ** G_tokenize(const char *buf, const char *delim)
Tokenize string.
Definition: gis/token.c:48
char * G_store(const char *s)
Copy string to allocated memory.
Definition: strings.c:86
char * dst
Definition: lz4.h:599
FILE * G_fopen_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database file for reading
Definition: open_misc.c:210
int G_is_initialized(int *p)
Definition: counter.c:59
int G_fwrite_key_value(FILE *fd, const struct Key_Value *kv)
Write key/value pairs to file.
Definition: key_value2.c:25
char * GPJ_grass_to_wkt2(const struct Key_Value *proj_info, const struct Key_Value *proj_units, const struct Key_Value *proj_epsg, int esri_style, int prettify)
Converts a GRASS co-ordinate system representation to WKT style. EPSG code is preferred if available...
Definition: convert.c:152
#define NULL
Definition: ccmath.h:32
void G_initialize_done(int *p)
Definition: counter.c:76
void G_free_key_value(struct Key_Value *kv)
Free allocated Key_Value structure.
Definition: key_value1.c:103
void G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
Definition: gis/error.c:160
struct Cell_head wr_window
Definition: R.h:100
struct state * st
Definition: parser.c:103
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
Builds full path names to GIS data files.
Definition: file_name.c:38
#define DCELL_TYPE
Definition: raster.h:13
RASTER_MAP_TYPE Rast_map_type(const char *name, const char *mapset)
Determine raster data type.
Definition: raster/open.c:879
double north
Extent coordinates (north)
Definition: gis.h:436
struct GDAL_link * Rast_create_gdal_link(const char *name, RASTER_MAP_TYPE map_type)
Create GDAL settings for given raster map.
Definition: gdal.c:415
#define FALSE
Definition: gis.h:53
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: debug.c:65
fclose(fd)
#define GPATH_MAX
Definition: gis.h:151
struct Key_Value * G_get_projinfo(void)
Gets projection information for location.
Definition: get_projinfo.c:58
Definition: gis.h:479
void Rast_set_d_null_value(DCELL *dcellVals, int numVals)
To set a number of DCELL raster values to NULL.
Definition: null_val.c:155
int cols
Number of columns for 2D data.
Definition: gis.h:409
struct Key_Value * G_get_projepsg(void)
Gets EPSG information for the current location.
Definition: get_projinfo.c:85
double ns_res
Resolution - north to south cell size for 2D data.
Definition: gis.h:430
void Rast_init_gdal(void)
Initialization.
Definition: gdal.c:214
Definition: path.h:16
FILE * G_fopen_new_misc(const char *dir, const char *element, const char *name)
open a new database file
Definition: open_misc.c:182
#define _(str)
Definition: glocale.h:13
void G_message(const char *msg,...)
Print a message to stderr.
Definition: gis/error.c:90
int RASTER_MAP_TYPE
Definition: raster.h:25
const char * G_find_raster2(const char *name, const char *mapset)
Find a raster map (look but don&#39;t touch)
Definition: find_rast.c:76
#define FCELL_TYPE
Definition: raster.h:12
void Rast_close_gdal_link(struct GDAL_link *gdal)
Close existing GDAL link.
Definition: gdal.c:574
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
int
Reads the categories file for map name in mapset and stores the categories in the pcats structure...
void G_set_key_value(const char *key, const char *value, struct Key_Value *kv)
Set value for given key.
Definition: key_value1.c:38
int nbytes
Definition: R.h:94
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.
Definition: gis/open.c:253
const char * name
Definition: named_colr.c:7
double ew_res
Resolution - east to west cell size for 2D data.
Definition: gis.h:426
int rows
Number of rows for 2D data.
Definition: gis.h:405
struct state state
Definition: parser.c:102
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition: gis/error.c:204
struct GDAL_link * Rast_get_gdal_link(const char *name, const char *mapset)
Get GDAL link settings for given raster map.
Definition: gdal.c:237
struct Key_Value * G_create_key_value(void)
Allocate and initialize Key_Value structure.
Definition: key_value1.c:23