我正在尝试使用 tmap 和简单的功能制作一张与美国其他州分开的地图。我轻推坐标所需的数量(在下面的示例中为东部地区) - 但出于某种原因,佛罗里达州和纽约州拒绝移动。我尝试在循环外手动调整,结果相同。如果我想将 sf 对象移动一个常数,那么接近它的最佳方法是什么?
还有——为什么密歇根看起来像融化在密歇根湖里?
library(tmap)
library(tmaptools)
library(tigris)
us_geo <- states(class = "sf")
us_geo$PADD[us_geo$NAME %in%
c("Maine", "Vermont", "New Hampshire", "Massachusetts", "Connecticut", "Rhode Island",
"New York", "Pennsylvania", "New Jersey", "Delaware", "District of Columbia", "Maryland",
"West Virginia", "Virginia", "North Carolina", "South Carolina", "Georgia", "Florida")] <- "East Coast"
us_geo$PADD[us_geo$NAME %in%
c("South Dakota", "North Dakota","Nebraska", "Kansas", "Oklahoma",
"Minnesota", "Iowa", "Missouri", "Wisconsin", "Illinois", "Indiana",
"Michigan", "Ohio", "Kentucky", "Tennessee")] <- "Midwest"
us_geo$PADD[us_geo$NAME %in%
c("New Mexico", "Texas", "Arkansas", "Louisiana", "Alabama", "Mississippi")] <- "Gulf Coast"
us_geo$PADD[us_geo$NAME %in%
c("Montana", "Idaho", "Wyoming", "Utah", "Colorado")] <- "Rocky Mountain"
us_geo$PADD[us_geo$NAME %in%
c("Washington", "Oregon", "Nevada", "Arizona", "California")] <- "West Coast"
us_geo <- us_geo[!is.na(us_geo$PADD),]
x <- grep("East", us_geo$PADD)
for(i in x){
us_geo[i,]$geometry[[1]][[1]][[1]][,1] <- us_geo[i,]$geometry[[1]][[1]][[1]][,1] +5
}
qtm(us_geo)