ramnathv / rCharts

Interactive JS Charts from R
http://rcharts.io
Other
1.19k stars 654 forks source link

Any way to make chloropleth maps with the Leaflet() function? #197

Open sckott opened 11 years ago

sckott commented 11 years ago

Like these http://leafletjs.com/examples/choropleth.html

ramnathv commented 11 years ago

Yes. It needs some modifications to the Leaflet class, so that most of the javascript is abstracted away, and only a familiar ggplot2 style mapping interface is exposed to the end-user. I have had it on my to-do list for some time, and it is time to whip up a working prototype, and push to github.

For starters, it will only support US based choropleth maps, but I believe the function would be flexible enough to extend to support other maps. I will post back here once I have a working draft.

Are you looking for this in connection with one of the rOpenSci packages?

sckott commented 11 years ago

Great, thanks.

I am doing a workshop demonstrating working with climate data in R with some of our package, and want to show how to make graphics, including interactive graphics using rCharts. I want to make interactive versions of chloropeth maps here https://github.com/ropensci/rWBclimate (see bottom of README), but could restrict examples to the US perhaps. If US only, I can use other data sets too, for example using data from here https://github.com/ropensci/rbison#with-any-data-returned-from-a-bison-call-you-can-choose-to-plot-county-or-state-level-data

ramnathv commented 11 years ago

Actually, world maps shouldn't be a problem. Let me whip up an rChoropleth function that will help. For now, most of the data processing like computing fill colors for regions will have to be done in R by the user. But, it should be possible to write some helper functions that abstract this away as well. I will look at your function interface and see if I can build something that follows it closely.

sckott commented 11 years ago

Great, thanks

jpolonsky commented 10 years ago

Hi Ramnath, thank you for your work. Did you ever get around to creating this function? At the moment I am plotting points without any problem, but would like to also plot polygons. Thanks again

kevinykuo commented 9 years ago

@ramnathv any updates on choropleths with leaflet for the js-challenged among us?

related https://github.com/ramnathv/rCharts/issues/105