Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geographical heat map in R

Tags:

r

map

i want to create a map of the US in R with the states color coded in a heat map type of way based on a metric. I know how to do this using the googleVis api but i can't use the code and without the rollovers it's not that great. what is the quickest way to get this done? i'm familiar with the maps package but i can't get the colors to cooperate. i believe this is called a choropleth map.

like image 422
hawkhandler Avatar asked Oct 13 '11 00:10

hawkhandler


People also ask

Can you make a heat map in R?

heatmap() function in R Language is used to plot a heatmap. Heatmap is defined as a graphical representation of data using colors to visualize the value of the matrix.

How do I map a location in R?

The most basic way to map data in R is to create a regular ggplot object and map longitude to the x aesthetic and latitude to the y aesthetic. You can use this technique to create maps of geographic areas, like states or countries, and to map locations as points, lines, and other shapes.

What is a geographical heat map?

Geographic heat maps are a type of visualization that displays the geographic distribution of data, typically using color or shading. Heat maps are generally used to represent data where the geographic location of items is important.

How do I create a world map in R?

To create a world map using it we will use the geom_map() function of the ggplot2 package of the R Language. This function returns a ggplot object so all the functions that work on other ggplot plots will be working in geom_map() too. where, data: determines the data be displayed in this layer.


2 Answers

There is a complete example in the ggplot2 package, see ?map_data.

library(ggplot2)
example(map_data)
like image 197
mdsumner Avatar answered Sep 24 '22 20:09

mdsumner


(hopefully answer may still be helpful for somebody)

RevolutionAnalytics has excellent example of map visualization using spplot() function. Here's image from there:

enter image description here

like image 29
ffriend Avatar answered Sep 22 '22 20:09

ffriend