Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>us.json</code> file used to draw the map has information about each counties' outline and their <a href="http://en.wikipedia.org/wiki/FIPS_county_code" rel="nofollow">FIPS code</a>:</p> <pre><code>{"type":"Polygon","arcs":[[250,-204,-17]],"id":30047} </code></pre> <p>Each row of <code>unemployment.tsv</code> represents a single county, containing its FIPS code and unemployment rate. When the file is loaded, it is converted from an array of objects:</p> <pre><code>&gt; unemployment [{id: '1001', rate: '.097'}, {id: '1004', rate: '.091'}, {id: '1005', rate: '.134'}, ... ] </code></pre> <p>to an object with the key as the county id and rate as the value:</p> <pre><code>var rateById = {}; unemployment.forEach(function(d) { rateById[d.id] = +d.rate; }); &gt; rateById {1001: .097, 1004: .091, 1005: .134} </code></pre> <p>(the <code>+d.rate</code> as casts the unemployment strings as numbers.)</p> <p>Once that is done, coloring each county is simple, just the shape's id to find the corresponding unemployment rate in <code>rateById</code> and convert that number to a color with the <code>color</code> scale.</p> <pre><code>.style("fill", function(d) { return color(rateById[d.id]); }); </code></pre> <p>To more directly answer your questions: you probably want to <a href="http://coastwatch.pfeg.noaa.gov/erddap/convert/fipscounty.html" rel="nofollow">code</a> your county level* data with country FIPS codes and use that to color your map. If you aren't working with by county data, you could try converting it (mapping lat/long or city/state to county) or use another kind of map entirely (for a world map, see <a href="http://bl.ocks.org/clayzermk1/4121134" rel="nofollow">this example</a> and the below comments).</p> <p>*I don't have any sort of GIS background - every time I try to do this, I end up using an old FIPS code -> county name look up table and have to correct a couple by hand; there is probably a better source file on the NIST website that I haven't been able to find. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload