0

I am working on a shape file and like to highlight some of the boundaries (borders) of the regions (as figure 1):

enter image description here

Figure 1: some but not all of the regions (borders) of the shape file are highlighted

(Source: https://dl.dropboxusercontent.com/u/48721006/highlighted.png)

The highlighting is achieved with ArcMap. I can't figure out how to do the same with R (particularly with the spplot()). Any suggestions on this?

To get the shape file

library(sp)
library(maptools)

con <- url("http://gadm.org/data/rda/ZAF_adm2.RData")

print(load(con))

close(con)

plot(gadm)

Many thanks!

G

radek
  • 7,240
  • 8
  • 58
  • 83

1 Answers1

3

What I would do: (1) plot the complete set; (2) take a subset; (3) plot the subset with a different line type. For subsetting shape files, check this question.

plot(gadm)

# check class and structure of the data
class(gadm)
head(gadm@data)

# take a subset based on ID_2
some_polygons = subset(gadm,ID_2>=38840 & ID_2<38850)
plot(some_polygons, add=T, border='cyan', lwd=2)
Community
  • 1
  • 1
koekenbakker
  • 3,524
  • 2
  • 21
  • 30