[GRASS-dev] how to add metadata in a raster file?
hamish_nospam at yahoo.com
Wed Nov 8 22:51:54 EST 2006
Yann Chemin wrote:
> while modifying a Landsat7 import module to read data from the .met
> (metadata) file,
> i wondered how i could store some of this useful information as
> appendix to the raster layer created.
> What is the way to do that in C?
yes, but it is a quite limitted. (40 lines x 80 columns for comments section)
from the command line you can use "r.support title=" to set a title,
and "r.support comment=" to add a comment. This is viewable with r.info.
In C it is done with the History struct, see lib/gis/history.c
see any number of raster modules that output a map, e.g. r.in.xyz:
/* close raster file & write history */
G_short_history(outmap, "raster", &history); /* init hist structure */
G_command_history(&history); /* wrote command line to comments */
strncpy(history.datsrc_1, infile, RECORD_LEN); /* fill in data source line */
history.datsrc_1[RECORD_LEN-1] = '\0'; /* strncpy() doesn't null terminate if maxfill */
G_write_history(outmap, &history); /* write hist structure to disk */
you need to do this *after* you've already closed the map, and then pass
the hist fns the string containing the map name.
More information about the grass-dev