首页 > 解决方案 > 提取 BC 人口普查 shapefile

问题描述

我已经下载了加拿大人口普查级别多边形 shapefile 强文本(https://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/bound-limit-2011-eng.cfm)并导入到 R使用包中的readOGR函数rgdal

但是,我正在努力专门从不列颠哥伦比亚省提取 shapefile。我已经使用前面的一些解释成功地提取了我的美国州邮政编码(Choropleth Maps in R - TIGER Shapefile issue)。

我需要帮助来提取 BC shapefile。

标签: rgeospatial

解决方案


我不知道您从该网站选择了哪个地理区域或水景。我已下载省/地区的数字边界文件。我已使用以下命令阅读和子集不列颠哥伦比亚省 shapefile

library(rgdal)

df <- readOGR(dsn = "C:\\Users\\User\\Desktop\\gpr_000a11a_e", layer = "gpr_000a11a_e")

#To see the data head
head(df@data)

#To see a particular column of the shapefile
df@data$PRENAME

#Subsetting British Columbia from the shapefile
BC = subset(df, PRENAME=="British Columbia")

#Plotting it
plot(BC)

推荐阅读