3

Does anybody know how to plot any attribute of a shapefile with R?

For example, like this.

enter image description here

5

If you are looking for an interactive graphical view, mapview is the right choice. Use

## load packages
library(raster)
library(mapview)

## download data
esp <- getData(country = "COL", level = 1)

## interactive plot
mapview(esp)

to display clickable polygons with a popup window showing you all the attribute values associated with a particular polygon. The package also features a version of spplot to display maps created via mapview statically (note that the function is still under heavy development).

## static plot
m <- mapview(esp)

spplot(m, zcol = "NAME_1", zoom = 6, 
       colorkey = FALSE, scales = list(draw = TRUE))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.