GRASS GIS 8 Programmer's Manual 8.3.2(2024)-exported
Loading...
Searching...
No Matches
find_rast.c File Reference
#include <grass/gis.h>
Include dependency graph for find_rast.c:

Go to the source code of this file.

Functions

const char * G_find_raster (char *name, const char *mapset)
 Find a raster map.
 
const char * G_find_raster2 (const char *name, const char *mapset)
 Find a raster map (look but don't touch)
 

Function Documentation

◆ G_find_raster()

const char * G_find_raster ( char *  name,
const char *  mapset 
)

Find a raster map.

Looks for the raster map name in the database. The mapset parameter can either be the empty string "", which means search all the mapsets in the user's current mapset search path (see Mapset_Search_Path for more details about the search path) or it can be a specific mapset name, which means look for the raster map only in this one mapset (for example, in the current mapset). If found, the mapset where the raster map lives is returned. If not found, the NULL pointer is returned.

Note: If the user specifies a fully qualified raster map which exists, then G_find_raster() modifies name by removing the "@<i>mapset</i>".

For example, to find a raster map anywhere in the database:

char name[GNAME_MAX];
char *mapset;
if ((mapset = G_find_raster(name,"")) == NULL)
// not found
#define NULL
Definition ccmath.h:32
const char * G_find_raster(char *name, const char *mapset)
Find a raster map.
Definition find_rast.c:55
const char * name
Definition named_colr.c:6

To check that the raster map exists in the current mapset:

char name[GNAME_MAX];
// not found
const char * G_mapset(void)
Get current mapset name.
Definition mapset.c:33
Parameters
[in,out]namemap name
mapsetmapset name or ""
Returns
mapset where raster map was found
NULL if not found

Definition at line 55 of file find_rast.c.

References G_debug(), G_find_file(), and name.

◆ G_find_raster2()

const char * G_find_raster2 ( const char *  name,
const char *  mapset 
)

Find a raster map (look but don't touch)

The same as G_find_raster() but doesn't remove the "@<i>mapset</i>" qualification from name, if present.

Returns NULL if the map wasn't found, or the mapset the raster was found in if it was.

Parameters
namemap name
mapsetmapset name or ""
Returns
mapset where raster map was found
NULL if not found

Definition at line 76 of file find_rast.c.

References G_debug(), G_find_file2(), and name.

Referenced by G_check_input_output_name(), Gs_build_256lookup(), Gs_get_cat_label(), GS_load_att_map(), Gs_loadmap_as_bitmap(), Gs_loadmap_as_char(), Gs_loadmap_as_float(), Gs_loadmap_as_int(), Gs_loadmap_as_short(), Gs_numtype(), Gs_pack_colors(), Gs_pack_colors_float(), gsd_put_legend(), IL_create_bitmask(), M_do_remove(), and M_do_rename().