[GRASS-user] Exporting labels of a raster

Paulo van Breugel p.vanbreugel at gmail.com
Thu Jul 14 05:14:50 EDT 2011


Just a slight off topic remark concerning the append text labels to your
grass raster layer. I think you might want to try out r.category. That way
you label your original raster rather then creating an additional (reclass)
layer with labels.

As for the question, I agree with previous comments, exporting the raster
and a separate text file with the legend is probably the best (only?) way to
go.


On Fri, Jul 1, 2011 at 2:20 PM, Rainer M Krug <r.m.krug at gmail.com> wrote:

>
>
> On Fri, Jul 1, 2011 at 2:06 PM, Luisa Peña <luisapena1979 at gmail.com>wrote:
>
>> Hello Rainer
>> I'm using reclass in order to have a raster with text lables (land use
>> land cover class names). I thought that r.reclass would be the only way to
>> have that.
>> and My reclass file is something like this:
>> 1 = 1 Urban
>> 2 = 2 Agriculture
>> 3 = 3 Irrigated Agriculture
>> 4 = 4 Forests
>> 5 = 5 Shrubland
>> * = NULL
>> Do you have any alternative suggestion to have labels in LULC?
>>
>
> It depends what you want to do with the raster.
>
> For labelling, this is the right approach.
>
> So when you use r.mapcalc "new_map=@existing_map"
>
> this will assume that the labels of your input map are numeric. Are your
> labels numeric or characters?
>
> From the help:
>
> ##########################
> RASTER MAP LAYER VALUES FROM THE CATEGORY FILE
>
> Sometimes it is desirable to use a value associated with a category's label
> instead of the category value itself. If a raster map layer name is preceded
> by the @ operator, then the labels in the category file for the raster map
> layer are used in the expression instead of the category value.
> For example, suppose that the raster map layer soil.ph (representing soil
> pH values) has a category file with labels as follows:
>
> cat label
> ------------------
> 0 no data
> 1 1.4
> 2 2.4
> 3 3.5
> 4 5.8
> 5 7.2
> 6 8.8
> 7 9.4
> Then the expression:
>
> result = @soils.ph
> would produce a result with category values 0, 1.4, 2.4, 3.5, 5.8, 7.2, 8.8
> and 9.4.
>
> Note that this operator may only be applied to raster map layers and
> produces a floating point value in the expression. Therefore, the category
> label must start with a valid number. If the category label is integer, it
> will be represented by a floating point number. I the category label does
> not start with a number or is missing, it will be represented by NULL (no
> data) in the resulting raster map.
> ##########################
>
>
> Cheers,
>
> Rainer
>
>
>> THanks
>> Luisa
>>
>> 2011/7/1 Rainer M Krug <r.m.krug at gmail.com>
>>
>>>
>>>
>>> On Fri, Jul 1, 2011 at 1:24 PM, Luisa Peña <luisapena1979 at gmail.com>wrote:
>>>
>>>> It didn't work. I get all full of NaNs map.
>>>> I used this:
>>>>     input="LUlabel at Study"
>>>>     grass.run_command("g.region", rast = input)
>>>>     grass.mapcalc("$output= @$labels", labels=input, output="Giovanni2")
>>>>
>>>> What am I doing wrong on this?
>>>>
>>>
>>> NaN means Not a Number - were your labels non-numeric?
>>> I *think* that raster can only have numeric cell values
>>>
>>> Rainer
>>>
>>>
>>>
>>>>  Luisa
>>>>
>>>> 2011/7/1 Giovanni Manghi <giovanni.manghi at gmail.com>
>>>>
>>>>> Hi,
>>>>>
>>>>>
>>>>> >
>>>>> > I have a raster map to wich I have applied r.reclass to add labels to
>>>>> > raster classes.  When I try to export this raster with the classes I
>>>>> > loose the lablels I only stick with the values.
>>>>> > In a script how can edit this raster in order to be exported with the
>>>>> > labels?Thanks
>>>>>
>>>>>
>>>>> r.mapcalc "new_map=@existing_map"
>>>>>
>>>>> then export "new_map" to tiff as usual.
>>>>>
>>>>> Cheers
>>>>>
>>>>> -- Giovanni --
>>>>>
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> grass-user mailing list
>>>> grass-user at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/grass-user
>>>>
>>>>
>>>
>>>
>>> --
>>> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
>>> Biology, UCT), Dipl. Phys. (Germany)
>>>
>>> Centre of Excellence for Invasion Biology
>>> Stellenbosch University
>>> South Africa
>>>
>>> Tel :       +33 - (0)9 53 10 27 44
>>> Cell:       +33 - (0)6 85 62 59 98
>>> Fax (F):       +33 - (0)9 58 10 27 44
>>>
>>> Fax (D):    +49 - (0)3 21 21 25 22 44
>>>
>>> email:      Rainer at krugs.de
>>>
>>> Skype:      RMkrug
>>>
>>>
>>
>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology,
> UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax (F):       +33 - (0)9 58 10 27 44
>
> Fax (D):    +49 - (0)3 21 21 25 22 44
>
> email:      Rainer at krugs.de
>
> Skype:      RMkrug
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20110714/41e21213/attachment.html


More information about the grass-user mailing list