GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
mask_info.c File Reference

Raster Library - Get mask information. More...

#include <string.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
Include dependency graph for mask_info.c:

Go to the source code of this file.

Functions

char * Rast_mask_info (void)
 Get a printable text with information about raster mask. More...
 
char * Rast_mask_name (void)
 Retrieves the name of the raster mask to use. More...
 
bool Rast_mask_status (char *name, char *mapset, bool *is_mask_reclass, char *reclass_name, char *reclass_mapset)
 Get raster mask status information. More...
 
int Rast__mask_info (char *name, char *mapset)
 Get information about the current mask. More...
 
bool Rast_mask_is_present (void)
 Check presence of 2D raster mask. More...
 

Detailed Description

Raster Library - Get mask information.

(C) 1999-2024 by Vaclav Petras and the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
CERL
Vaclav Petras, NC State University, Center for Geospatial Analytics

Definition in file mask_info.c.

Function Documentation

◆ Rast__mask_info()

int Rast__mask_info ( char *  name,
char *  mapset 
)

Get information about the current mask.

Determines the status of the automatic masking and the name of the 2D raster which forms the mask. Typically, mask is raster called MASK in the current mapset, but when used with r.mask, it is usually a reclassed raster, and so when a MASK raster is present and it is a reclass raster, the name and mapset of the underlying reclassed raster are returned.

The name and mapset is written to the parameter which need to be defined with a sufficient size, least as char name[GNAME_MAX], mapset[GMAPSET_MAX].

When the masking is not active, -1 is returned and name and mapset are undefined. When the masking is active, 1 is returned and name and mapset will hold the name and mapset of the underlying raster.

Parameters
[out]nameName of the raster map used as mask
[out]mapsetName of the map's mapset
Returns
1 if mask is present, -1 otherwise

Definition at line 143 of file mask_info.c.

References G_find_raster(), G_mapset(), G_strlcpy(), GMAPSET_MAX, GNAME_MAX, name, Rast_is_reclass(), and strcpy.

Referenced by Rast_mask_info(), and Rast_mask_status().

◆ Rast_mask_info()

char* Rast_mask_info ( void  )

Get a printable text with information about raster mask.

Determines if 2D raster mask is present and returns textual information about the mask suitable for end-user display. The resulting text is translated. Caller is responsible for freeing the memory of the returned string.

Returns
New string with textual information

Definition at line 31 of file mask_info.c.

References _, G_store(), GMAPSET_MAX, GNAME_MAX, name, Rast__mask_info(), and strcpy.

◆ Rast_mask_is_present()

bool Rast_mask_is_present ( void  )

Check presence of 2D raster mask.

Returns
true if mask is present, false otherwise

Definition at line 168 of file mask_info.c.

References G_find_raster(), G_mapset(), and NULL.

◆ Rast_mask_name()

char* Rast_mask_name ( void  )

Retrieves the name of the raster mask to use.

The returned raster map name is fully qualified, i.e., in the form % "name@mapset".

The mask name is "MASK@<mapset>", where <mapset> is the current mapset.

The memory for the returned mask name is dynamically allocated using G_store(). It is the caller's responsibility to free the memory with G_free() when it is no longer needed.

Returns
A dynamically allocated string containing the mask name.

Definition at line 67 of file mask_info.c.

References G_fully_qualified_name(), and G_mapset().

◆ Rast_mask_status()

bool Rast_mask_status ( char *  name,
char *  mapset,
bool *  is_mask_reclass,
char *  reclass_name,
char *  reclass_mapset 
)

Get raster mask status information.

is_mask_reclass is a pointer to a bool variable which will be set to true if mask raster is a reclass and false otherwise.

If you are not interested in the underlying reclassified raster map, pass NULL pointers for the three reclass parameters:

#define NULL
Definition: ccmath.h:32
bool Rast_mask_status(char *, char *, bool *, char *, char *)
Get raster mask status information.
Definition: mask_info.c:94
const char * name
Definition: named_colr.c:6
Parameters
[out]nameName of the raster map used as mask
[out]mapsetName of the mapset the raster is in
[out]is_mask_reclassWill be set to true if mask raster is a reclass
[out]reclass_nameName of the underlying reclassified raster map
[out]reclass_mapsetName of the mapset the reclassified raster is in
Returns
true if mask is present, false otherwise

Definition at line 94 of file mask_info.c.

References G_mapset(), name, Rast__mask_info(), Rast_is_reclass(), and strcpy.