[GRASS-user] How to add labels to raster non-interactively?

Glynn Clements glynn at gclements.plus.com
Thu Oct 4 15:25:55 EDT 2007


Rainer M. Krug wrote:

> I have a raster which has very large cell values (>10^10) which I can 
> not store in the grid directly.

Do you have to use integers? A DCELL (double-precision floating point)
map can store integers up to 2^53 (~10^16) exactly.

> Therefore I have at the moment category 
> values of 1-6 and 1 represents 10^10. As I want to use mapcalc with 
> these values, I want to use labels to store the large numbers in, but as 
> I have to do it for a large number of maps (which are generated during 
> simulations) I can't do it manually by using r.support interactively.
> 
> Therefore my question: is there a way to either store the values in the 
> grid cell itself instead of the category value or if not, how can I 
> create these labels non-interactively?

The cats file format is simple enough that you could generate it from
a script. See the cats files for the sample datasets (e.g. Spearfish)
for examples.

Generating a cats file using the libgis functions is also quite
straightforward e.g.:

	const char *map_name = "outmap";
	const char title[] = "title string";
	const char *labels[NUM_CATS] = { ... };
	struct Categories cats;

	G_init_cats(0, title, &cats);

	for (i = 0; i < NUM_CATS; i++)
		G_set_cat(i, (char *) labels[i], &cats);

	G_write_cats ((char *) map_name, &cats);

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-user mailing list