如何在 R 中的国家地图中为特定区域着色?
How to color specific districts in a country map in R?
我绘制了砂拉越州(在马来西亚国家)的地图以及地区级别的边界,如图所示。
但是我的问题是,如何为特定地区(两个或更多)着色?有人可以帮助我吗,砂拉越的任何地区都可以作为例子。代码如下:
#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)
我绘制了砂拉越州(在马来西亚国家)的地图以及地区级别的边界,如图所示。
但是我的问题是,如何为特定地区(两个或更多)着色?有人可以帮助我吗,砂拉越的任何地区都可以作为例子。代码如下:
#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)