[Rspatial-devel] draw a map

maria jesus herrerias mjherreriast at gmail.com
Mon Nov 7 21:44:01 CET 2011


Dear users,

I am quite new in this topic, so sorry in advanced if it is a simple
question.
I have a couple of questions that may be some of you know and can help me
to solve my problem.

1. I will like to add the name of the Chinese provinces in the map  with
the variable "var1", see below the code.

2. I will like to put different colors depending on different thresholds
of the variable "var1" in a map with a leyend, but without using the defult
scale.

Thanks in advanced.

Maria

---------------------------------
The script is as following:

install.packages("sp")
library(sp)

#load the map #
mapchina<- url("http://www.gadm.org/data/rda/CHN_adm1.RData")


load(mapchina)
mapchina=gadm

summary(gadm)


gadm$NAME_1   #shows the name of the Chinese regions

#create the vector of data that we want to draw in the Chinese map,. Notice
that follow the same order that NAME_1 #

valor=c(99.09,70.62,0,49.13,42.13,40.53,46.10,40.36,0,71.87,38.71,
82.36,69.76,62.68,76.17,70.43,47.96,42.34,49.65,44.42,0,41.19,66.42,
61.04,76.75,82.75,44.69,75.37,20.53,21.25,38.10,89.74)

var1<-data.frame(valor)

# add the vector of data into the map

mapa at data=data.frame(var1)

#plot the map

spplot(mapa,c("var1"))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rspatial-devel/attachments/20111107/10bffe45/attachment.htm>


More information about the Rspatial-devel mailing list