Reputation: 1
I hope you're doing well.
I currently have data from the US with values for magnitude and zip code. Similar to:
Magnitude | Zip_code |
---|---|
1 | 00001 |
2 | 00002 |
I would like to do two things with this data: create a map showing the number of responses by zip code and interpolate a heat map for magnitude across the country. Ideally, I would like to produce maps similar to:
An example from this thread, producing heat map over Geo locations in R
Is there any easy way to do this in R? Thank you so much.
I started using the choroplethrZip package, but I'm not sure how to use it. I'm sorry for the inconvenience.
Upvotes: 0
Views: 984
Reputation: 5398
Here is an example of how I use choroplethrZip
library.
The key point is that the value column must be called value, and the zip code column must be called "region". The zip code data must be character/string values that match the internal function source data.
A data.frame with a column named "region" and a column named "value". Elements in the "region" column must exactly match how regions are named in the "region" column in ?zip.map.
#install_github('arilamstein/[email protected]')
library(choroplethrZip)
water<-structure(list(region = c("32034", "32081", "32082", "32092",
"32097", "32202", "32204", "32205", "32206", "32207", "32208",
"32209", "32210", "32211", "32216", "32217", "32218", "32219",
"32220", "32221", "32222", "32223", "32224", "32225", "32226",
"32233", "32234", "32244", "32246", "32250", "32254", "32256",
"32257", "32258", "32259", "32277"), value = c(284, 368, 337,
338, 280, 247, 247, 260, 227, 253, 220, 244, 209, 309, 298, 270,
256, 282, 267, 216, 156, 240, 283, 304, 242, 254, 180, 188, 301,
301, 267, 334, 240, 240, 310, 258)), row.names = c(NA, -36L),
class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"))
zip_choropleth(water,
zip_zoom = (water$region),
num_colors = 1,
title = "Jacksonville FL Area Water Hardness by Zip Code",
legend = "PPM")
Data Source: https://www.jea.com/About/Water_Supply/Water_Hardness_Levels/
Upvotes: 2