Skip to content

Instantly share code, notes, and snippets.

@djvanderlaan
Created February 1, 2013 10:58
Show Gist options
  • Save djvanderlaan/73833ec90a8a77b0e29f to your computer and use it in GitHub Desktop.
Save djvanderlaan/73833ec90a8a77b0e29f to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<div id="vis"></div>
<script>
// Map properties
var xmin = 13565.400;
var xmax = 306846.900;
var ymin = 277992.800;
var ymax = 619305.599;
var height = 400;
var scale = height/(ymax - ymin);
var width = Math.ceil((xmax - xmin) * scale);
projection = function(coordinates) {
return [ scale*(coordinates[0]-xmin),
height-scale*(coordinates[1]-ymin) ];
}
var path = d3.geo.path().projection(projection);
var vis = d3.select("#vis").append("svg")
.attr("width", width).attr("height", height)
d3.json("po_2012_simplified.json", function(json) {
vis.selectAll("path").data(json.features).enter().append("path")
.attr("d", path)
.style("fill", "red")
.style("stroke-width", "1")
.style("stroke", "black")
});
</script>
</body>
</html>
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment