当我尝试用Hobo-Dyer投影绘制地图时,它告诉我:
Error in st_crs.character(x[[shape.id[masterID]]]$projection) : invalid crs: hd
这是我的代码:
tm_shape(countries_spdf, projection = "hd") +
tm_grid(n.x = 11, n.y = 11) +
tm_fill(col = "population", style = "quantile") +
tm_borders(col = "burlywood4")
我该怎么办?
我相信tm_shape的投影功能已经更改为仅接受代表所需CRS的整数,即它仍然适用于4326,这是业内最常见的一种。但是,使用ggplot库中的coord_map可以使用解决方法,我在下面包含:
tm_shape(countries_spdf, projection = 4326) +
tm_grid(n.x = 11, n.y = 11) +
tm_fill(col = "population", style = "quantile") +
tm_borders(col = "burlywood4")
tm_shape(countries_spdf, projection = coord_map("hr")) +
tm_grid(n.x = 11, n.y = 11) +
tm_fill(col = "population", style = "quantile") +
tm_borders(col = "burlywood4")
希望这有帮助