Skip to content

Instantly share code, notes, and snippets.

@bricedev
Last active February 29, 2024 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bricedev/fbb8d8e848d790e2fa88 to your computer and use it in GitHub Desktop.
Save bricedev/fbb8d8e848d790e2fa88 to your computer and use it in GitHub Desktop.
SF police districts

Sf police districts map.

<!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>

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

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@funnycones
Copy link

i hate u.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment