0

我在使用关岛和马里亚纳群岛的底格里斯群岛形状文件时遇到问题:

  1. 格里斯关岛地图没有提供任何城市信息,但许多人口普查数据集包括关岛的城市。底格里斯河 文件包括对市政当局的提及。谁能推荐关岛市多边形/形状文件的另一个来源?
  2. 使用tigris中的功能未正确下载马里亚纳群岛。我已经包含了我的解决方法,但我希望能够直接访问这些信息。

.

library(tigris)
library(ggplot2)
library(ggthemes)
library(dplyr)

## Working Puerto Rico Map ----
# Downloads map
PR_map <- counties(72, cb = T) 
# Converts shapefile for ggplot2
PR_map <- ggplot2::fortify(PR_map, region = "COUNTYFP")
# Adds random data
PR_map <- merge(PR_map, data.frame(id = unique(PR_map$id), value = rep(1:4, (length(unique(PR_map$id)) %/% 4 + 4))[1:length(unique(PR_map$id))]), by = "id")
# Plots map
ggplot(PR_map)+geom_map(map = PR_map, aes(x=long, y=lat, fill = value, map_id=id), color="white", size=0.25)+ coord_map("mercator")+ theme_map()

## Broken Guam Map (No municipalities)----
# Downloads map
GU_map <- counties(66, cb = T) 
# Converts shapefile for ggplot2
GU_map <- ggplot2::fortify(GU_map, region = "COUNTYFP")
# Adds random data
GU_map <- merge(GU_map, data.frame(id = unique(GU_map$id), value = rep(1:4, (length(unique(GU_map$id)) %/% 4 + 4))[1:length(unique(GU_map$id))]), by = "id")
# Plots map
ggplot(GU_map)+geom_map(map = GU_map, aes(x=long, y=lat, fill = value, map_id=id), color="white", size=0.25)+ coord_map("mercator")+ theme_map()

## Broken Call for Mariana Islands 
# Does not download Mariana Islands, instead it downloads the entire United States and Territories 
USA_map <- counties(69, cb = T) 

# My work around is to subset to the appropriate region:
MI_map <- subset(USA_map, USA_map$STATEFP == "69")

# Converts shapefile for ggplot2
MI_map <- ggplot2::fortify(MI_map, region = "COUNTYFP")
# Adds random data
MI_map <- merge(MI_map, data.frame(id = unique(MI_map$id), value = rep(1:4, (length(unique(MI_map$id)) %/% 4 + 4))[1:length(unique(MI_map$id))]), by = "id")
# Plots map (The hex turns the map sideways for better viewing.)
ggplot(MI_map)+geom_map(map = MI_map, aes(x=long, y=lat, fill = value, map_id=id), color="white", size=0.25)+ coord_map("hex")+ theme_map()
4

1 回答 1

0
  1. 关岛问题的解决方案是使用“地点”功能。
  2. 错误已修复。tigris的维护者 Kyle Walker更新了应用程序以响应这篇文章和相关的推文。见推文。
于 2018-04-09T18:37:18.910 回答