I am trying to make a choropleth of very simple data, and it's kind of a pain in the neck. I have the following zip codes in the Eastern USA. This is made up data but you get the idea.
etc. for about 100 rows. Values of Freq range from 0-1000, and these are the ones I would like to use to determine the color of each zipcode. I would ideally also like the map to focus on the Eastern USA instead of the whole country.
I want to make a choropleth with this data and each zip code but I can't figure out how to import zip code shapefiles. I have tried this tutorial but I got an error at the fortify() step that I can't get beyond. I'm not sure if that tutorial's method is even the best way to go about it.
ggplot2 seems to come with State and County, but I can't figure out how to map by zip code. (Eventually I am going to map by census tract but right now I just want to learn how to use shapefiles for zip codes and this simple data set)
Photos related to Refrence United States area Code Map (20 photos) Always remembers to follow the next image gallery, which also contains the United States Area Code Map Inspirationa Best Us Zip Code Map Svg photo showed above. Us Map Postal Zip Code Map 2000px Zip Code Zones Svg, Download this wallpaper for free in high resolution. Us Map Postal Zip Code Map 2000px Zip Code Zones Svg was posted in January 16, 2018 at 3:25 pm and This Us Map Postal Zip Code Map 2000px Zip Code Zones Svg Wallpaper has viewed by 185 users. I'm sorry if this is the wrong sub-reddit for this. I'm a data analyst for a small not-for-profit organization and have a background in amateur graphic design. We want to make a custom map of our service area for our employees to use when working with clients. What I've been trying to find is an SVG file of the zip-codes in Missouri.
All the resources I have found for choroplethr use functions that are now deprecated. I spent hours chasing my tail in an effort to use it, and am so frustrated, so any help would be greatly appreciated.
garsongarsonThank you for using choroplethr
, and I'm sorry that the deprecation of zip_map
caused you problems. I have moved all ZIP related functions to a separate packaged called choroplethrZip.
The old verion of choroplethr rendered ZIPs as scatterplots, not choropleths. Rendering them as proper choropleths required a map that is too large for CRAN (~60MB), which is why it is only available via github.
The github page I link to above has 3 vignettes. Basically, the function zip_choropleth
should do exactly what you want, and work like all the other choroplethr
functions. You want to use the state_zoom
to zoom in on the east coast states:
The resulting map is essentially unreadable because the zips are so small that all you can see are the borders. If you want to remove the borders, try this:
In the future, I might add an option that makes it easier to render the maps with no borders. But for now (version 1.3.0) this is the easiest way I can see to do it, and is basically what I do behind the scenes to render the national zip maps, which themselves are rendered without borders.
Note that coord_map
just forces a mercator projection.
<!DOCTYPE html> |
<metacharset='utf-8'> |
<style> |
.zip { |
fill: none; |
stroke: #CCC; |
stroke-width: .5px; |
} |
</style> |
<body> |
<scriptsrc='http://d3js.org/d3.v3.min.js'></script> |
<scriptsrc='http://d3js.org/queue.v1.min.js'></script> |
<scriptsrc='http://d3js.org/topojson.v1.min.js'></script> |
<script> |
var width =960, |
height =500; |
var path =d3.geo.path(); |
var svg =d3.select('body').append('svg') |
.attr('width', width) |
.attr('height', height); |
queue() |
.defer(d3.json, 'zips_us_topo.json') |
.await(ready); |
functionready(error, us) { |
svg.append('g') |
.attr('class', 'counties') |
.selectAll('path') |
.data(topojson.feature(us, us.objects.zip_codes_for_the_usa).features) |
.enter().append('path') |
.attr('class', 'zip') |
.attr('data-zip', function(d) {returnd.properties.zip; }) |
.attr('data-state', function(d) {returnd.properties.state; }) |
.attr('data-name', function(d) {returnd.properties.name; }) |
.attr('d', path); |
} |
</script> |
</body> |
Hi Jeffriesen, Thank you so much for the helpful code. Do you have any tips for how to create a .shp / .json file for a single state while keeping the zip codes as a property? I tried topojson .. -p ZIP, but I think it failed because I haven't found a proper California .shp file that includes zip code information. The zipcodes_for_the_usa file is great, but I only want California. Thanks! |
Rockin' gist @jefffriesen |
I was actually looking for the same thing as @roesler-stan.is there a way to easily parse this file into separate topo.json files by state? |
@RussRezek and @roesler-stan I just spent several hours doing this, because I couldn't find any current open data online. Compiled and simplified topojson with makefile at https://github.com/storiesofsolidarity/us-data/tree/gh-pages/geography/zcta Note, these are ZCTAs not actual zipcode routes. |
Much appreciated @jlev. I'm still having trouble scaling them properly using python Vincent, but I think it has something to do with the projections that I am using. They look fine in http://mapshaper.org. |
Not sure if this is relevant for anyone, but I created some GeoJSON files here grouping the zip codes in @jefffriesen's TopoJSON by Metropolitan Statistical Area (MSA). |
Can anybody help me? I need to get the zipcodes map, unfortunately the geocommons link is not available anymore.. I need the full USA ZIP Code map, including Alaska.. anybody knows how can i get it? I've been looking for that map for almost 3 weeks @jefffriesen |
Any luck finding anything @Oscarsgc? Genuine mazda oe gear lever shift boot kit mx5 mk1 mk2 mk2.5 1. In the same boat as you. this topojson dataset is great, it's just seems to be missing Alaska (AK) and Hawaii (HI) which can be presented nicely with the albersUSA projection - as can be seen here: https://bl.ocks.org/mbostock/4060606 |
Hi @jefffriesen, Best, |
@jefffriesen - what is your recommendation to get a latest version of zips_us_topo.json(data)? |