Report not found

There was a problem finding this report.
Military Surplus Gear Bought for Local Police
August 21, 2014 · Refreshed about 5 years ago
Description
Map of the value of military surplus gear provided to local law enforcement. Value in dollars per county resident. Data provided by New York Times (Article source: http://www.nytimes.com/2014/08/20/upshot/data-on-transfer-of-military-gear-to-police-departments.html?abt=0002&abg=1 Raw data source: https://github.com/TheUpshot/Military-Surplus-Gear).

Collaborators

Run History
SELECT gear.state, c.county_name, c.combined_code, pop.popestimate2013 AS population, COUNT(*) AS items, SUM(quantity*acquisition_cost) AS spent FROM benn.nytimes_military_surplus_gear gear JOIN benn.county_codes c ON c.state = gear.state AND UPPER(c.short_name) = gear.county JOIN benn.county_data pop ON pop.state = c.state_code AND pop.county = c.county_code GROUP BY 1,2,3,4
SELECT gear.state, c.county_name, c.combined_code, pop.popestimate2013 AS population, COUNT(*) AS items, SUM(quantity*acquisition_cost) AS spent FROM benn.nytimes_military_surplus_gear gear JOIN benn.county_codes c ON c.state = gear.state AND UPPER(c.short_name) = gear.county JOIN benn.county_data pop ON pop.state = c.state_code AND pop.county = c.county_code GROUP BY 1,2,3,4
<style> h2 { text-align: center; font-size: 18px; } .counties { fill: #ccc; } .states { fill: none; stroke: #fff; stroke-linejoin: round; } .county:hover { fill: green !important; } svg { width: auto; height: auto; } .d3-tip { line-height: 1.2; padding: 12px; background: rgba(0, 0, 0, 0.8); color: #fff; text-align: center; border-radius: 2px; width: 220px; } </style> <h2>Value of Military Gear Provided to Local Law Enforcement</h2> <div id="map"></div> <body> <script src="//cdnjs.cloudflare.com/ajax/libs/queue-async/1.0.4/queue.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/topojson/1.1.0/topojson.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/d3-tip/0.6.3/d3-tip.min.js"></script> <script src="//cdn.rawgit.com/mbostock/d3/master/lib/colorbrewer/colorbrewer.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js"></script> <script> var width = Math.max(Math.min($(window).width(),950),300), height = Math.round(width*(2/3)); if (width < 660) { topMargin = 15; } else { topMargin = 0; }; var rateById = d3.map(); var nameById = d3.map(); var path = d3.geo.path(); var colors = colorbrewer.Reds[6]; var projection = d3.geo.albersUsa() .scale(width*1.3) .translate([width/2, height/2]); var path = d3.geo.path() .projection(projection); var svg = d3.select("#map").append("svg") .attr("width", width) .attr("height", height + topMargin); data = dataset.content; data.forEach( function(d) { rateById.set(d.combined_code, (d.spent/d.population)); nameById.set(d.combined_code, d.county_name); }) var inc = _.pluck(data,"combined_code") var c = d3.scale.quantize() .domain([0,100]) .range(colors); var tip = d3.tip() .attr('class', 'd3-tip') .direction(function(d) { c = path.centroid(d.geometry) if (c[0] <= width/2) { return 'e'; } else { return 'w'; } }) .offset(function(d) { c = path.centroid(d.geometry) if (c[0] <= width/2) { return [0,10]; } else { return [0,-10]; } }) .html(function(d) { return nameById.get(d.id) + "</br>$" + d3.round(rateById.get(d.id),2); }); queue() .defer(d3.json, "https://dl.dropboxusercontent.com/s/sh04tjwairb7vgk/counties.json") .await(ready); g = svg.append("g").attr("transform", "translate(0," + topMargin + ")"); svg.call(tip) function ready(error, us) { g.append("g") .attr("class", "counties") .selectAll("path") .data(topojson.feature(us, us.objects.counties).features) .enter().append("path") .attr("class",function(d) { if (inc.indexOf(d.id) != -1) { return "county"; } }) .style("fill", function(d) { return c(rateById.get(d.id)); }) .attr("d", path) d3.selectAll(".county") .on("mouseover",tip.show) .on("mouseout",tip.hide); g.append("path") .datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; })) .attr("class", "states") .attr("d", path); var legendText = [0,100] if (width > 660) { legendX = height; legendY = 40; } else { legendX = width/2 - 40; legendY = 0; } g.selectAll(".legend-bars") .data(colors) .enter().append("rect") .attr("class","legend-bars") .attr("x",function(d,i) { return legendX + (i*20); }) .attr("y",legendY) .attr("width",20) .attr("height",8) .style("fill",function(d) { return d; }) g.selectAll(".bar-text") .data(legendText) .enter().append("text") .attr("class","bar-text") .attr("x",function(d,i) { return legendX + 5 + (i*20*(colors.length-1)); }) .attr("y",legendY - 4) .text(function(d,i) { if (i != 1) { return "$" + d; } else { return "$" + d + " per resident"; } }); } </script>
{{ dataSourceName(params.queryId) }}

The dataset is too large to view in browser

Export

Looks like something went wrong with your query.

{{ DS.queryRuns[params.queryId].errorMessage }}
This query was cancelled