我想为spplot()上的区域添加名称标签.
例:
load(url('http://gadm.org/data/rda/FRA_adm0.RData'))
FR <- gadm
FR <- spChFIDs(FR, paste("FR", rownames(FR), sep = "_"))
load(url('http://gadm.org/data/rda/CHE_adm0.RData'))
SW <- gadm
SW <- spChFIDs(SW, paste("SW", rownames(SW), sep = "_"))
load(url('http://gadm.org/data/rda/DEU_adm0.RData'))
GE <- gadm
GE <- spChFIDs(GE, paste("GE", rownames(GE), sep = "_"))
df <- rbind(FR, SW, GE)
## working
plot(df)
text(getSpPPolygonsLabptSlots(df), labels = c("FR", "SW", "GE"))
## not working
spplot(df[1-2,])
text((getSpPPolygonsLabptSlots(df), labels = c("FR", "SW"))
Run Code Online (Sandbox Code Playgroud)
第二个可能因为格子而无法工作!?但是,我需要spplot功能.我如何获得情节上的标签?
该数据
代码
#
# This is code for mapping of CGE_Morocco results
#
# rm(list = ls(all = TRUE)) # don't use this in code that others will copy/paste
## Loading packages
library(rgdal)
library(plyr)
library(maps)
library(maptools)
library(mapdata)
library(ggplot2)
library(RColorBrewer)
## Loading shape files administrative coordinates for Morocco maps
#Morocco <- readOGR(dsn=".", layer="Morocco_adm0")
MoroccoReg <- readOGR(dsn=".", layer="Morocco_adm1")
## Reorder the data in the shapefile based on the regional order
MoroccoReg <- MoroccoReg[order(MoroccoReg$ID_1), ]
## Add the yield impacts column to …Run Code Online (Sandbox Code Playgroud)