Tmap - highligh borders


I'd like to higlight "inner borders" in tmap so that it would like this


Do you have any advice?

Thank you!

I don't really now tmap, I personnaly plot everything i need on maps with ggplot2 + sf (geom_sf).

For me it is quite a simple thing to do,
Your first add your inner borders (with a light color) to the map then add the bigger ones.
The inner border width must be less or equal than the ohter ones.

I hope it helped you a little.

You probably want something like this:

tm_shape(okresy("low")) + tm_fill("grey70") + tm_borders("gray80") +
  tm_text("NAZ_LAU1", size = 1/2) +
  tm_shape(kraje("low")) + tm_borders(col = "gray50")

You will likely need to tune some of the parameters (such as size of the font, perhaps replace some of the spaces with newlines etc.) but the code should be enough to get you started.

The key part is to use two tm_shape calls - first the smaller regions with light tm_borders call, and then the big regions with darker tm_borders call.


Thank you very much!

May I ask if you don't know by any chance how to adjust the overlapping labels?

I used 'tm_text("NAZ_KRAJ",size=0.5,auto.placement = FALSE,remove.overlap=T)'

but it didn't help.

Thank you once again!

{tmap} places labels in centroids, and there is not much you can do with it; this is a big issue with Prague / Středočeský kraj. Auto.placement is random, and thus not easily reproducible (set.seed() may help). xmod and ymod are applied to all labels equally, so will not help with overlap.

If you are not dead set on using {tmap} you may consider plotting via {ggplot2} and use {ggrepel} - this is what I would do.

Also, consider transforming your coordinate reference system to WGS84, so that north is up; the Křovák projection looks kind of strange :slight_smile:

Thank you. Could you be more specific how to transofrm the coordinate reference system?

Certainly; transforming coordinate reference systems can be done easily via sf::st_transform(your_object, new_crs), where new_crs should be 4326 (usually a good default), whereas your original CRS is likely 5514 (Systém jednotné trigonometrické sítě katastrální - created ages ago by inž. Křovák to fit the area from Aš to Mukačevo)

1 Like

Thank you!

Do you know why I receive 'Error: C stack usage 7971344 is too close to the limit' when I try RCzechia?

Thank you


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.