简体   繁体   English

如何在 map 上重新定位 position (ggplot/sf/geometry)

[英]How to relocate the position on the map (ggplot/sf/geometry)

I am using R to draw a map of China and the USA.我用R画了一个中美map。 I would like to map the "holistic thinking" across these two countries.我想 map 跨越这两个国家的“整体思维”。 Could you help me with the followings?你能帮我解决以下问题吗?

  1. relocate these two countries?搬迁这两个国家? There is too much space between the two countries.两国之间的空间太大了。 I would like to narrow the space between the two countries and zoom the size of the two countries.我想缩小两国之间的距离,放大两国的面积。
  2. smaller the size of "Alaska"? “阿拉斯加”的大小更小? I think the size of Alaska is too big relative to the size of the USA.我认为阿拉斯加的面积相对于美国的面积来说太大了。

This is my code.这是我的代码。

holistic_10_plot1 <- st_read(" two_triad_current ") %>%
ggplot() +
geom_sf(aes(fill = holistic_10_province)) +
scale_fill_gradient(low = "lightblue", high = "darkblue") +
geom_sf_text(aes(label = province_current), color = "grey", family = "sans", angle = 0) +
theme_void() +
labs(title = "The number of holistic groups(10 focal groups) \n current states/provinces") +
theme(legend.position = "bottom", plot.title = element_text(hjust = 0.5), title = element_text(size = 14, face = "bold", color = "black")) +
guides(fill = guide_colorbar(title = "The number of the holistic groups", title.position = "top"))

This is the plot.这是 plot。

enter image description here在此处输入图像描述

to relocate the positon of China or the USA to make them closer.重新定位中国或美国的位置,使它们更接近。

You can shift an sf object simply by recalculating its geometry column like so:您可以简单地通过重新计算其几何列来移动sf object,如下所示:

library(sf)

## create example sf object "nc":
nc <- st_read(system.file("shape/nc.shp", package="sf"))

add another geometry column (or change it in place):添加另一个几何列(或就地更改它):

library(sf)

## shift geometry .1 degrees east and .1 degrees north:
nc$shifted_geometry <-  nc |> st_geometry() + c(.1, -.1)

plot original and shifted geometry: plot 原始几何和移位几何:

nc |> st_geometry() |> plot()
nc$shifted_geometry |> plot(add = TRUE, border = 'red')

移位几何

Concerning the area, you could set an equal-area projection with st_transform() .关于面积,您可以使用st_transform()设置等面积投影

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM