r - 提取 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。
解决方案
我不知道您从该网站选择了哪个地理区域或水景。我已下载省/地区的数字边界文件。我已使用以下命令阅读和子集不列颠哥伦比亚省 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)
推荐阅读
- ruby - col 如何在 Ruby 代码中获取其值:Array.new(cells) { |col| PolarCell.new(行,列)}
- visual-studio-code - Visual Studio Code 等待和弦的第二个键。(Ctrl + A)
- c# - Xamarin Forms,HttpClient 类 - GetStringAsync 和 GetAsync 返回空值并快速退出函数
- git - git'在angular2中不被识别为内部或外部命令、可运行程序或批处理文件
- laravel - 如何将徽标保存到公用文件夹中
- matrix - 为什么 Julia 在某些情况下不能识别 NaN?
- elasticsearch - 将非索引字段(JSON)存储为对象而不是 Elasticsearch 中的文本是否有任何额外开销
- javascript - TypeScript - 基于枚举比较的 Switch 语句直接进入 DefaultCase
- mysql - 如何选择每个组的最后一个条目?
- apache-spark - Pyspark 忽略 pyspark-sql-functions 中数据帧的过滤