GRASS 8 Programmer's Manual 8.6.0dev(2026)-f6f2c534ea
Loading...
Searching...
No Matches
raster_metadata.c File Reference

Raster library - Functions to read and write raster "units", "semantic label" and "vertical datum" meta-data info. More...

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

Go to the source code of this file.

Functions

charRast_read_units (const char *name, const char *mapset)
 Get a raster map's units metadata string.
 
void Rast_write_units (const char *name, const char *str)
 Write a string to a raster map's units metadata file.
 
charRast_read_vdatum (const char *name, const char *mapset)
 Get a raster map's vertical datum metadata string.
 
void Rast_write_vdatum (const char *name, const char *str)
 Write a string into a raster's vertical datum metadata file.
 
charRast_read_semantic_label (const char *name, const char *mapset)
 Get a raster map semantic label metadata string.
 
charRast_get_semantic_label_or_name (const char *name, const char *mapset)
 Get a raster map semantic label or fall back to its name.
 
void Rast_write_semantic_label (const char *name, const char *str)
 Write a string into a rasters semantic label metadata file.
 
bool Rast_legal_semantic_label (const char *semantic_label)
 Check for legal semantic label.
 

Detailed Description

Raster library - Functions to read and write raster "units", "semantic label" and "vertical datum" meta-data info.

(C) 2007-2009, 2021 by Hamish Bowman, Maris Nartiss, 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
Hamish Bowman

Definition in file raster_metadata.c.

Function Documentation

◆ Rast_get_semantic_label_or_name()

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

Get a raster map semantic label or fall back to its name.

Use this function if a semantic label is needed but not mandated.

Parameters
nameraster map name
mapsetmapset name
Returns
string representing semantic label or map name

Definition at line 111 of file raster_metadata.c.

References G_store(), name, and Rast_read_semantic_label().

Referenced by I_iclass_init_signatures(), I_sort_signatures_by_semantic_label(), and I_SortSigSetBySemanticLabel().

◆ Rast_legal_semantic_label()

bool Rast_legal_semantic_label ( const char semantic_label)

Check for legal semantic label.

Legal semantic label must be a legal GRASS file name. Semantic labels are capped in length to GNAME_MAX.

This function will return false if provided semantic label is not considered to be valid. This function does not check if semantic label maps to any entry in metadata files of semantic labels as not all semantic labels have files with extra metadata.

The function prints a warning on error.

Parameters
semanticlabel reference to check
Returns
true success
false failure

Definition at line 154 of file raster_metadata.c.

References _, G_legal_filename(), G_warning(), and GNAME_MAX.

◆ Rast_read_semantic_label()

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

Get a raster map semantic label metadata string.

Read raster semantic label metadata file and put string in to str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing semantic label on success
NULL on error

Definition at line 96 of file raster_metadata.c.

References name.

Referenced by Rast_get_semantic_label_or_name().

◆ Rast_read_units()

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

Get a raster map's units metadata string.

Read the raster's units metadata file and put string in str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing units on success
NULL on error

Definition at line 38 of file raster_metadata.c.

References name.

◆ Rast_read_vdatum()

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

Get a raster map's vertical datum metadata string.

Read the raster's vertical datum metadata file and put string in str

Parameters
nameraster map name
mapsetmapset name
Returns
string representing vertical datum on success
NULL on error

Definition at line 67 of file raster_metadata.c.

References name.

◆ Rast_write_semantic_label()

void Rast_write_semantic_label ( const char name,
const char str 
)

Write a string into a rasters semantic label metadata file.

Raster map must exist in the current mapset.

It is up to the caller to validate semantic label string in advance with Rast_legal_semantic_label().

Parameters
nameraster map name
strstring containing data to be written

Definition at line 130 of file raster_metadata.c.

References name.

◆ Rast_write_units()

void Rast_write_units ( const char name,
const char str 
)

Write a string to a raster map's units metadata file.

Raster map must exist in the current mapset.

Parameters
nameraster map name
strstring containing data to be written

Definition at line 51 of file raster_metadata.c.

References name.

◆ Rast_write_vdatum()

void Rast_write_vdatum ( const char name,
const char str 
)

Write a string into a raster's vertical datum metadata file.

Raster map must exist in the current mapset.

Parameters
nameraster map name
strstring containing data to be written

Definition at line 80 of file raster_metadata.c.

References name.