[R] R help, using R to build choropleth

Pascal Oettli kridox at ymail.com
Thu Jun 28 08:53:24 CEST 2012


Hello,

You can find some hints there:
http://geography.uoregon.edu/geogr/topics/index.html

Regards


Le 12/06/28 14:26, iverson a écrit :
> Hi guys
>
> i need some help to build choropleth.
>
> Basically i am trying to colour regions on the map by population.
>
> I possess the shape file of the country, and also the population data,
> however, i am having trouble to create the plot, below is my code:
>
>
>
> population=read.csv("nz2.csv")
> population
> names(population)
>
> nz=readShapeSpatial((sprintf('nz-geodetic-marks',tmp_dir)))
>
> nz$land_distr
>
> mapnames = nz$land_distr
>
> mapnamesnew=as.character(mapnames)
>
> popnames =as.character(mapnamesnew)
> pop =population$People
>
> pop2=as.numeric(pop)
>
> popdich = ifelse(pop2 < 100000, "red", "blue")
> popnames.lower = tolower(popnames)
>
> cols=popdich[match(mapnames,popnames.lower)]
>
> plot(nz,fill=TRUE,col=cols,proj="GCS_NZGD_2000")
>
>
>
>
> thanks in advance for any assistance
>
> Kind regards
>
> Iverson
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/R-help-using-R-to-build-choropleth-tp4634686.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list