These national, departmental, and municipal boundaries for Guatemala are extracted from a single, topology-encoded GeoJSON file using D3 and TopoJSON. Original shapefiles were sourced from the GADM database of Global Administrative Areas.
Last active
October 24, 2018 16:40
-
-
Save wsvekla/4348435 to your computer and use it in GitHub Desktop.
Guatemala TopoJSON
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> | |
path { | |
fill: none; | |
stroke: #000; | |
stroke-width: .5px; | |
} | |
.country { | |
stroke-width: 1px; | |
} | |
.municipality { | |
stroke: #aaa; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v0.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500; | |
var projection = d3.geo.mercator() | |
.center([-90.22, 15.78]) | |
.scale(6700); | |
var path = d3.geo.path() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.json("guatemala.json", function(error, topology) { | |
svg.append("path") | |
.datum(topojson.object(topology, topology.objects.guatemala0)) | |
.attr("d", path) | |
.attr("class", "country"); | |
svg.append("path") | |
.datum(topojson.mesh(topology, topology.objects.guatemala1, function(a,b){return a.id !== b.id;})) | |
.attr("d", path) | |
.attr("class", "department"); | |
svg.append("path") | |
.datum(topojson.mesh(topology, topology.objects.guatemala2, function(a,b){return a.id !== b.id;})) | |
.attr("d", path) | |
.attr("class", "municipality"); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment