block by bricedev fbb8d8e848d790e2fa88

SF police districts

Full Screen

Sf police districts map.

index.html

<!DOCTYPE html>
<meta charset="utf-8">
<style>

.district {
  fill: #ccc;
  stroke: #333;
  stroke-width: .7px;
}

.district :hover {
  fill: #845b46;
}

</style>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script>
<script>

var width = 960,
    height = 700;

var path = d3.geo.path()
    .projection(null);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

d3.json("sfp.json", function(error, sfp) {
  if (error) throw error;

  var districts = svg.append("g")
      .attr("class","district")
    .selectAll("path")
      .data(topojson.feature(sfp, sfp.objects.sfpd_districts).features)
    .enter().append("path")
      .style("opacity", 0)
      .attr("d", path)
    
  districts.append("title")
    .text(function(d) { return d.properties.district; });

  districts.transition().ease("elastic").duration(500).delay(function(d,i) { return 100*i; }).style("opacity",.8);

});

d3.select(self.frameElement).style("height", height + "px");

</script>

makefile.md

topojson \
    --width 960 \
    --height 700 \
    --margin 20 \
    --properties id=OBJECTID \
    --properties district=DISTRICT \
    --properties company=COMPANY \
    -o sfp.json \
    -- sfpd_districts.shp