【问题标题】:tigris R Maps: Issues with Guam and Mariana Islands Maps底格里斯河 R 地图:关岛和马里亚纳群岛地图的问题
【发布时间】:2018-05-07 21:37:50
【问题描述】:

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

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

.

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()

【问题讨论】:

    标签: r mapping polygon census tigris


    【解决方案1】:
    1. 关岛问题的解决方案是使用“地点”功能。
    2. 错误已修复。 tigris 的维护者 Kyle Walker 更新了应用程序以回应这篇文章和相关的推文。见tweet.

    【讨论】:

      猜你喜欢
      • 2020-10-14
      • 1970-01-01
      • 2012-05-11
      • 2023-01-11
      • 1970-01-01
      • 2015-04-04
      • 1970-01-01
      • 2013-08-08
      • 2014-05-21
      相关资源
      最近更新 更多