Skip to content

Instantly share code, notes, and snippets.

@thiagomarzagao
Created February 1, 2015 20:04
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 thiagomarzagao/9ae1c1c9a9ff988aabdf to your computer and use it in GitHub Desktop.
Save thiagomarzagao/9ae1c1c9a9ff988aabdf to your computer and use it in GitHub Desktop.
plot Brazil
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 960,
height = 1160;
/*
var projection = d3.geo.albers()
.center([0, 55.4])
.rotate([4.4, 0])
.parallels([50, 60])
.scale(1200 * 5)
.translate([width / 2, height / 2]);
*/
var projection = d3.geo.albers()
.center([-47, -15])
.rotate([4.4, 0])
.parallels([-30, 15])
.scale(1200)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
/*
d3.json("uk.json", function(error, uk) {
console.log(uk)
svg.append("path")
.datum(topojson.feature(uk, uk.objects.subunits))
.attr("d", path);
});
*/
d3.json("br-states.json", function(error, mymap) {
console.log(mymap)
svg.append("path")
.datum(topojson.feature(mymap, mymap.objects.states))
.attr("d", path);
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment