[GRASS-user] Using non-ASCII chartacters in r.reclass rules file

Greetings

I want to add labels to a Land use/cover map with integer numbers. I have produced a reclass file where I associate a number with a land Cover class name 1 = Water 2 = Forests …
and It works fine

Question: It seems that it is not possible to use non-ascii characters. Is it true? Is there any way to add labels to the classes and use characters (such as á;à;ó; â)

Thanks
Luisa

Luisa Peña wrote:

I want to add labels to a Land use/cover map with integer numbers. I have
produced a reclass file where I associate a number with a land Cover class
name 1 = Water 2 = Forests ...
and It works fine

Question: It seems that it is not possible to use non-ascii characters. Is
it true? Is there any way to add labels to the classes and use characters
(such as á;à;ó; â)

I don't know; what error (or other unexpected behaviour) are you
getting?

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

On 29/07/2011 20:26, Glynn Clements wrote:

Luisa Peña wrote:

I want to add labels to a Land use/cover map with integer numbers. I have
produced a reclass file where I associate a number with a land Cover class
name 1 = Water 2 = Forests ...
and It works fine

Question: It seems that it is not possible to use non-ascii characters. Is
it true? Is there any way to add labels to the classes and use characters
(such as á;à;ó; â)

I don't know; what error (or other unexpected behaviour) are you
getting?

I just applied the multi-lingual reclass rules below [1] to a Corine Land Cover file. No problems so far, apart from a somewhat zig-zagging output of r.report [2].

Hermann

[1]

1 = 111 Continuous urban fabric
2 = 112 Tejido urbano discontinuo
3 = 121 Industrial or commercial units
4 = 122 Redes viarias, ferroviarias y terrenos asociados
5 = 123 Zonas portuarias
6 = 124 Aeropuertos
7 = 131 Zonas de extracción minera
8 = 132 Escombreras y vertederos
9 = 133 Zonas en construcción
10 = 141 Green urban areas
11 = 142 Instalaciones deportivas y recreativas
12 = 211 Ikke-kunstvandede, dyrkede arealer
13 = 212 Permanent kunstvandede arealer
14 = 213 Rismarker
15 = 221 Vinmarker
16 = 222 Frugt- og bærplantager
17 = 223 Olivenplantager
18 = 231 Græsmarker
19 = 241 Etårige afgrøder i forbindelse med permanente afgrøder
20 = 242 Komplekst dyrkningsmønster
21 = 243 Overvejende landbrugsområde med stort islæt af naturlig vegetation
22 = 244 Agro-forestry areas (sydeuropæisk blandingskultur: agerafgrøder under å bent trædække)
23 = 311 Lövskog
24 = 312 Barrskog
25 = 313 Blandskog
26 = 321 Naturligt gräsbevuxen mark
27 = 322 Hedmark (utom gräshed)
28 = 323 Sclerophyllous vegetation
29 = 324 Transitional woodland/shrub
30 = 331 Stränder, dyner och sandslätter
31 = 332 Berg i dagen och blockmark
32 = 333 Områden med sparsam vegetation
33 = 334 Brandfält
34 = 335 Glaciärer och permanenta snöfält
35 = 411 Humedales y zonas pantanosas
36 = 412 Tourbières
37 = 421 Marismas
38 = 422 Salinas
39 = 423 Zone intertidali
40 = 511 Gewässerläufe
41 = 512 Láminas de agua
42 = 521 Coastal lagoons
43 = 522 Mündungsgebiete
44 = 523 Mares y océanos

[2]

|-----------------------------------------------------------------------------|
| Category Information | |
| #|description | hectares|
|-----------------------------------------------------------------------------|
|111|Continuous urban fabric. . . . . . . . . . . . . . . . . . . | 39|
|112|Tejido urbano discontinuo. . . . . . . . . . . . . . . . . . | 105,820|
|121|Industrial or commercial units . . . . . . . . . . . . . . . | 65,215|
|122|Redes viarias, ferroviarias y terrenos asociados . . . . . . | 1575|
|123|Zonas portuarias . . . . . . . . . . . . . . . . . . . . . . | 692|
|124|Aeropuertos. . . . . . . . . . . . . . . . . . . . . . . . . | 1696|
|131|Zonas de extracción minera. . . . . . . . . . . . . . . . . | 37,340|
|132|Escombreras y vertederos . . . . . . . . . . . . . . . . . . | 6632|
|133|Zonas en construcción . . . . . . . . . . . . . . . . . . . | 13,473|
|141|Green urban areas. . . . . . . . . . . . . . . . . . . . . . | 964|
|142|Instalaciones deportivas y recreativas . . . . . . . . . . . | 23,213|
|211|Ikke-kunstvandede, dyrkede arealer . . . . . . . . . . . . . | 138,608|
|221|Vinmarker. . . . . . . . . . . . . . . . . . . . . . . . . . | 75|
|222|Frugt- og bærplantager. . . . . . . . . . . . . . . . . . . | 6443|
|231|Græsmarker. . . . . . . . . . . . . . . . . . . . . . . . . | 338,105|
|242|Komplekst dyrkningsmønster. . . . . . . . . . . . . . . . . | 65,042|
|243|Overvejende landbrugsområde med stort islæt af naturlig. . | 15,620|
| |vegetation | |
|311|Lövskog . . . . . . . . . . . . . . . . . . . . . . . . . . | 18,005|
|312|Barrskog . . . . . . . . . . . . . . . . . . . . . . . . . . | 82,202|
|313|Blandskog. . . . . . . . . . . . . . . . . . . . . . . . . . | 34,365|
|321|Naturligt gräsbevuxen mark. . . . . . . . . . . . . . . . . | 22,163|
|322|Hedmark (utom gräshed). . . . . . . . . . . . . . . . . . . | 2792|
|324|Transitional woodland/shrub. . . . . . . . . . . . . . . . . | 189,036|
|331|Stränder, dyner och sandslätter. . . . . . . . . . . . . . | 3474|
|333|Områden med sparsam vegetation. . . . . . . . . . . . . . . | 20,345|
|411|Humedales y zonas pantanosas . . . . . . . . . . . . . . . . | 6371|
|412|Tourbières. . . . . . . . . . . . . . . . . . . . . . . . . | 1371|
|421|Marismas . . . . . . . . . . . . . . . . . . . . . . . . . . | 1406|
|423|Zone intertidali . . . . . . . . . . . . . . . . . . . . . . | 12,857|
|511|Gewässerläufe. . . . . . . . . . . . . . . . . . . . . . . | 205|
|512|Láminas de agua . . . . . . . . . . . . . . . . . . . . . . | 25,793|
|523|Mares y océanos . . . . . . . . . . . . . . . . . . . . . . | 6517|
| *|no data. . . . . . . . . . . . . . . . . . . . . . . . . . . | 98,752,546|
|-----------------------------------------------------------------------------|

Those characters are not displayed (they are replaced by blank spaces)
Luisa

2011/7/29 Glynn Clements <glynn@gclements.plus.com>

Luisa Peña wrote:

I want to add labels to a Land use/cover map with integer numbers. I have
produced a reclass file where I associate a number with a land Cover class
name 1 = Water 2 = Forests …
and It works fine

Question: It seems that it is not possible to use non-ascii characters. Is
it true? Is there any way to add labels to the classes and use characters
(such as á;à;ó; â)

I don’t know; what error (or other unexpected behaviour) are you
getting?


Glynn Clements <glynn@gclements.plus.com>

Hermann Peifer wrote:

>> Question: It seems that it is not possible to use non-ascii characters. Is
>> it true? Is there any way to add labels to the classes and use characters
>> (such as á;à;ó; â)
>
> I don't know; what error (or other unexpected behaviour) are you
> getting?

I just applied the multi-lingual reclass rules below [1] to a Corine
Land Cover file. No problems so far, apart from a somewhat zig-zagging
output of r.report [2].

That's to be expected. Modules which format text into columns
generally assume that one "char" equates to one column, which isn't
the case for a multi-byte encoding such as UTF-8. It shouldn't happen
with e.g. ISO-8859-*.

This isn't something which can easily be fixed.

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

Luisa Peña wrote:

> > Question: It seems that it is not possible to use non-ascii characters. Is
> > it true? Is there any way to add labels to the classes and use characters
> > (such as á;à;ó; â)
>
> I don't know; what error (or other unexpected behaviour) are you
> getting?

Those characters are not displayed (they are replaced by blank spaces)

Displayed where? In a terminal? wxGUI?

Are they present in the "cats" file when viewed in a text editor?

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

On 30/07/2011 23:12, Glynn Clements wrote:

Hermann Peifer wrote:

Question: It seems that it is not possible to use non-ascii characters. Is
it true? Is there any way to add labels to the classes and use characters
(such as á;à;ó; â)

I don't know; what error (or other unexpected behaviour) are you
getting?

I just applied the multi-lingual reclass rules below [1] to a Corine
Land Cover file. No problems so far, apart from a somewhat zig-zagging
output of r.report [2].

That's to be expected. Modules which format text into columns
generally assume that one "char" equates to one column, which isn't
the case for a multi-byte encoding such as UTF-8. It shouldn't happen
with e.g. ISO-8859-*.

This isn't something which can easily be fixed.

Thanks. I will just continue hoping that perhaps one day, GRASS will become multi-byte aware, like Gawk. Hermann

$ /usr/bin/printf "|%-10s|\n" aaa
|aaa |
$ /usr/bin/printf "|%-10s|\n" åæä
|åæä |
$ gawk 'BEGIN{printf "|%-10s|\n", "aaa"}'
|aaa |
$ gawk 'BEGIN{printf "|%-10s|\n", "åæä"}'
|åæä |

Hi
Sorry for not being clear.
When I try to display the legend, in Map Display Window, those characters are not displayed. Shall I add a print screen?
Luisa

2011/7/30 Glynn Clements <glynn@gclements.plus.com>

Luisa Peña wrote:

Question: It seems that it is not possible to use non-ascii characters. Is
it true? Is there any way to add labels to the classes and use characters
(such as á;à;ó; â)

I don’t know; what error (or other unexpected behaviour) are you
getting?

Those characters are not displayed (they are replaced by blank spaces)

Displayed where? In a terminal? wxGUI?

Are they present in the “cats” file when viewed in a text editor?

Glynn Clements <glynn@gclements.plus.com>

Luisa Peña wrote:

> > Those characters are not displayed (they are replaced by blank spaces)
>
> Displayed where? In a terminal? wxGUI?
>
> Are they present in the "cats" file when viewed in a text editor?

When I try to display the legend, in Map Display Window, those characters
are not displayed. Shall I add a print screen?

You'll need to select a font which has those characters (I don't think
that the default stroke fonts have accented characters), and also
select the correct encoding (presumably either ISO-8859-1 or UTF-8).

AFAICT, this has to be done globally, in the preferences. There
doesn't appear to be a way to set the font or encoding for an
individual layer.

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