[Rspatial-devel] draw a map
Roger Bivand
Roger.Bivand at nhh.no
Mon Nov 7 22:31:18 CET 2011
On Mon, 7 Nov 2011, maria jesus herrerias wrote:
> 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.
Please *do* write to the R-sig-geo list rather than to me directly -
others can answer your question as well, perhaps better, and in a more
timely way than I can. In addition, threads in the list can be searched in
the archives, so others can avoid the same problem later.
The list you wrote to is for developers rather than users.
Roger Bivand
>
> 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"))
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the Rspatial-devel
mailing list