Sf police districts map.
Last active
February 29, 2024 02:35
-
-
Save bricedev/fbb8d8e848d790e2fa88 to your computer and use it in GitHub Desktop.
SF police districts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i hate u.