Я скачал шейп-файл переписи на уровне почтового индекса, cb_2017_us_zcta510_500k.shp
(https://www.census.gov/geo/maps-data/data/cbf/cbf_zcta.html)
Я также скачал файл сопоставления, который позволяет мне добавить соответствующую переменную STATE
(https://www.census.gov/geo/maps-data/data/zcta_rel_download.html)
Я слил два, и я получил:
library(sf)
library(dplyr)
big_df
Simple feature collection with 44434 features and 2 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: -176.6847 ymin: -14.37374 xmax: 145.8304 ymax: 71.34122
epsg (SRID): 4269
proj4string: +proj=longlat +datum=NAD83 +no_defs
First 10 features:
ZCTA5CE10 STATE geometry
1 35442 1 MULTIPOLYGON (((-88.25262 3...
2 35442 1 MULTIPOLYGON (((-88.25262 3...
3 35442 1 MULTIPOLYGON (((-88.25262 3...
Теперь я попытался отфильтровать все маленькие острова и Аляску:
remove_list <- c("02", "15", "72", "66", "78", "60", "69",
"64", "68", "70", "74", "81", "84", "86", "87", "89", "71", "76",
"95", "79")
big_df %>% filter(!STATE %in% map(remove_list, as.integer)) %>%
tm_shape(.) + tm_polygons('pt_count',palette = "Reds",
style = "quantile", n = 10,
title = "counts")
но у меня все еще есть крошечные острова.
![enter image description here](https://i.stack.imgur.com/FjE1q.png)
Что мне здесь не хватает?
Спасибо!