在 R 中绘制人口普查 shapefile 的倾斜地理

问题描述 投票:0回答:0

我已经按块提取美国人口普查数据,并手动将其上的块 shapefile 与

sf
rgdal
包合并。当我绘制生成的
sf
对象时,它显示了一个倾斜的地图,尽管
crs
在通过合并读入 shapefile 时保持不变。

形状文件可以在这里找到:https://www2.census.gov/geo/tiger/TIGER_RD18/LAYER/TABBLOCK20/,我正在使用的伊利诺伊州是

tl_rd22_17_tabblock20.zip
.

人口普查数据可以在这里找到:https://data.census.gov/table?q=population&g=0500000US17031$1000000&tid=DECENNIALPL2020.P1

这应该是一个 MWE:

library(ggplot2)
library(sf)
library(rgdal)
library(data.table)

dt_census <- fread(path_to_census_data)

blck_shp <- readOGR(dsn = block_shapefile_filepath, layer = "tl_rd22_17tabblock20")

blck_sf <- st_as_sf(blck_shp)

dt <- merge(blck_sf,dt_census, by.x = "GEOID20", by.y = "GEOID")

mini_dt <- dt[,c("POP20","geometry")]
mini_dt$POP20 <- as.numeric(mini_dt$POP20)

plot(mini_dt)

但这会产生一个倾斜的地块,东北部的一些街区显然位于城市线之外并进入密歇根湖。

r geospatial sf rgdal census
© www.soinside.com 2019 - 2024. All rights reserved.