Reputation: 1
I am using R to draw a map of China and the USA. I would like to map the "holistic thinking" across these two countries. Could you help me with the followings?
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.
to relocate the positon of China or the USA to make them closer.
Upvotes: 0
Views: 326
Reputation: 6911
You can shift an sf
object simply by recalculating its geometry column like so:
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:
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()
.
Upvotes: 1