tmap icon indicating copy to clipboard operation
tmap copied to clipboard

png/svg symbols for tm_symbols and symbol rotation?

Open oiramkawon opened this issue 4 years ago • 4 comments

Is it possible to use custom svg/png icons as shape in tm_symbols()? And is it possible to rotate the symbols based on data variable?

oiramkawon avatar Dec 06 '21 12:12 oiramkawon

Hi @oiramkawon I can partially answer the first question - yes, it is possible - see the last example at https://r-tmap.github.io/tmap-book/visual-variables.html#shapes.

Nowosad avatar Dec 06 '21 13:12 Nowosad

Thanks a lot, good to know. But how are the icons assosciated to the points? When a point has an attribute "airport" how to choose the airport sign?

oiramkawon avatar Dec 06 '21 13:12 oiramkawon

The order of your icons should be the same as the order of the values of the provided variable (usually alphabetic one).

Nowosad avatar Dec 06 '21 13:12 Nowosad

Thanks for your question. We hadn't thought about rotation for symbols as an aesthetic yet, but it sure is! In tmap3 it is not possible yet (unfortunately), but I plan to add it in tmap4.

In the second last example of tm_symbols there is one that uses a custom airplane.png icon.

If you want to use multiple icon (on for each category), you'll have to specify this with tmap_icons. In addition to @Nowosad 's last answer, the number of icons should correspond to the number of categories. It is good practice to use a factor data variable.

Important thing: you'll have to specify the icons with the argument shapes (which behaves the same as a color palette for col/fill aesthetics), and the data variable name with shape.

mtennekes avatar Jan 06 '22 16:01 mtennekes