我目前正在尝试将北卡罗来纳州的所有邮政编码映射到传单地图上。最终,我想用来自另一个数据集的值对这些进行颜色编码。
虽然我已经设法用这些值将标记放在地图上,但以带有邮政编码的彩色方式这样做确实会为我的项目增加价值。
我在 R 中下载了 USAboundaries 库,因此我认为我有足够的数据在传单中创建多边形,但数据不是 SpatialPointsDataFrame 格式。
USAboundaries 数据集的示例输出如下所示:
USAboundaries::us_zipcodes()
Simple feature collection with 33144 features and 6 fields
geometry type: POINT
dimension: XY
bbox:
xmin: -176.6316
ymin: -14.22075
xmax: 145.7536
ymax: 71.2738
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs
First 10 features:
zipcode zcta5ce10 affgeoid10 geoid10 aland10 awater10 geometry
21914 21914 8600000US21914 21914 1924479 477175 POINT (-75.98187 39.57303)
01001 01001 8600000US01001 01001 29731610 2118827 POINT (-72.62585 42.06258)
34736 34736 8600000US34736 34736 322808220 78588518 POINT (-81.89624 28.55458)
46151 …Run Code Online (Sandbox Code Playgroud)