我正在使用形状文件绘制 tmap 绘图,并且我想在形状文件上绘制几个具有长纬度坐标的点。我的绘图工作得很好,但是地图上有太多点,这意味着不同点的标签文本是重叠的,并且一般来说不是特别清晰。
here's what the plot currently looks like.
i would really like for the text in the plot to be outside of the actual map, and to be connected to the points in the plot by thin lines which blend into the overall aesthetic of the map.
这是一些示例数据:
name long lat
1 location -71.40909 41.82426
2 location -71.41959 41.82796
3 location -71.41277 41.79667
4 location -71.37327 41.81737
5 location -71.37170 41.89266
6 location -71.33356 41.87736
这是我必须显示上面的图的代码:
我们假设上面的数据框是plot2_points.df
, while shapes
是底层形状文件。
library(tmap)
library(sp)
library(rgdal)
coordinates(plot2_points.df) <- c("long", "lat")
proj4string(plot2_points.df) <- CRS("+proj=longlat +datum=WGS84")
plot2_points.df <- spTransform(plot2_points.df, CRS("+proj=utm +zone=19T ellps=WGS84"))
# plot
tm_shape(shapes) + tm_borders() + tm_shape(plot2_points.df) + tm_dots(col = "blue", size = 0.4) + tm_text("name", col = "blue", size = 0.75, just = "top", ymod = 0.75)
我还没有找到任何可以做到这一点的功能。tm_lines()
不起作用,但我觉得这是为了完全不同的东西。另外,也许与just =
选项?到目前为止,我尝试过的任何方法都没有任何效果,所以我想我应该在这里问。任何帮助将不胜感激,非常感谢:)