简体   繁体   English

如何从 shapefile 中选择特定区域?

[英]How can I select specific regions from a shapefile?

I have the present shapefile我有现在的 shapefile

heitaly<- readOGR("ProvCM01012017/ProvCM01012017_WGS84.shp")

FinalData<- merge(italy, HT, by.x="COD_PROV", by.y="Domain")

But I'm interesting not on all Italy, but also same provinces.但我感兴趣的不是整个意大利,还有相同的省份。 How can I get them?我怎样才能得到它们?

There are many ways to select a category into a shapefile.有多种方法可以将类别选择到 shapefile 中。 I don't know for what do you want.我不知道你想要什么。 For example if it is to colour a specific region in a plot or to select a row from shapefile attribute table.例如,如果要为绘图中的特定区域着色或从 shapefile 属性表中选择一行。

To plot:绘制:

plot(shape, col = shape$column_name == "element") # general example

plot(heitaly, col = heitaly$COD_PROV == "name of province") # your shapefile

To attribute table:到属性表:

df <- shape %>% data.frame This will give you the complete attribute table df <- shape %>% data.frame这将为您提供完整的属性表

row <- shape %>% data.frame %>% slice(1)

This will give you the first row with all columns.这将为您提供所有列的第一行。 If you change the number 1 to another number, for example 3, will give you the information for row number 3如果您将数字 1 更改为另一个数字,例如 3,将为您提供第 3 行的信息

I hope have been useful我希望有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 R 将区域从 shapefile 传输到 netcdf 文件? - How to transfer regions from a shapefile to a netcdf file using R? 如何从R中的shapefile中按属性消除某些区域并创建新的shapefile? - How can I eliminate some areas by attribute from a shapefile in R and create a new shapefile? 如何从 R 中的流统计 package 中提取分水岭 shapefile? - How can I extract the watershed shapefile from the streamstats package in R? 如何在 R Shiny 中动态选择导入 shapefile 的列以进行进一步分析? - How can I dynamically select columns of imported shapefile for further analysis in R Shiny? 如何将shapefile裁剪为R中的特定集? - How do I crop a shapefile to a specific set in R? 如何从r中的向量中选择或删除特定元素? - How can I select or remove specific element from vector in r? 如何“关闭”从多边形shapefile中绘制的geom_path? - How can I 'close' a geom_path plotted from a polygon shapefile? 如何创建具有多个shapefile数据集的for循环函数? - How can I create a for loop function with multiple shapefile datasets? 如何将 CSV 数据点加载到 R 中的 shapefile 中? - How can I load CSV data points onto a shapefile in R? 如何在R或ArcGIS中处理多边形shapefile中的“孤立孔”? - How can I handle an “orphaned hole” in a polygon shapefile in R or ArcGIS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM