[GRASS-user] How to add labels to raster non-interactively?
Rainer M Krug
Rainer+grass at krugs.de
Fri Oct 5 04:24:04 EDT 2007
Glynn Clements wrote:
> 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.
No - I don'y have to use integers - DCELL would be fine as well. but how
can I change the format? The raster is created from an imported shape file.
In a second step I want to use r.reclass() to create the second raster
which holds the large cell values. Can I specify in r.reclass() that the
cell values should be stored as DCELL?
>
>> 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);
>
Thanks - but as you suggested above, the DCELL solution appeals more to me.
More information about the grass-user
mailing list