0

I know tm_text() uses centroids to locate labels, however when I try to run the code using the Shapefiles from this webpage (Instituto Dominicano de Datos Espaciales): (https://geoportal.iderd.gob.do/layers/geonode_data:geonode:RD_PROV/metadata_detail) the map locates the provinces names way outside. This is the map I want to replicate with the names exactly in the middle.

enter image description here

The code I use is:

library(tmap)
library(rgdal)
library(dplyr)
library(sf)
library(maptools)
library(rgeos)


map_prov <-  readOGR("RD_PROV.shp")
map_REG <- st_read("RD_REG_20220630.shp")

tmap_mode("plot") + tm_shape(map_prov) +
tm_borders(col="blue") + tm_text("TOPONIMIA", size = "AREA")

The result I get is:(https://i.stack.imgur.com/TFUGR.png)

I need the provinces names more cleanly located as shown above. Also if you know a way to wrap text as shown in first map, it would be great.

jazzurro
  • 23,179
  • 35
  • 66
  • 76
almr27
  • 43
  • 4
  • "Middle" and "exactly" can be surprisingly vague when dealing with irregular shapes. Dos this help - https://stackoverflow.com/questions/74869220/how-to-force-text-displayed-by-the-tm-text-function-of-rs-tmap-to-remain-inside ? For wrapping text labels - https://stackoverflow.com/questions/47446259/wrapping-long-geom-text-labels & https://stackoverflow.com/questions/66760349/wrapping-geom-text-geom-label-on-ggplot-r?noredirect=1&lq=1 – margusl Jun 30 '23 at 11:11

0 Answers0