如何在R中的国家/地区地图中为特定区域着色?

时间:2020-07-29 16:17:41

标签: r mapping spatial

我已绘制了砂拉越州(马来西亚)的地图以及地区级别的边界,如图所示。 enter image description here

但是我的问题是,如何为特定区域(两个或多个)着色?有人可以帮我吗,砂拉越的任何地区都可以作为例子。代码如下:

#sarawak map with divisions
library(raster)

#country Malaysia with all boundaries at the district level
Malaysia <- getData('GADM', country='MYS', level=2)
#listing all districts in every states in Malaysia e.g. there are 32 districts for Sarawak state
Malaysia$NAME_1

#plotting Sarawak with all districts and their boundaries
Sarawak <- Malaysia[98:128,]
plot(Sarawak)

1 个答案:

答案 0 :(得分:0)

让我开始向所有人推荐CRAN,单击“程序包”链接,然后单击“ CRAN Task Views”链接。该页面按适用范围概括收集软件包;关于地图和地图以及GEOS等的整个章节。

对于您的特殊情况,我认为软件包maptools here中的某些工具是为地图中指定区域着色的。