#Test Archivo shp convertido a geojson y topojson sin usar linea de comando. Usando Qgis para pasar el shp a geojson y Mapshaper para convertir el geojson a topojson (barriosTopo.json). Fuente del shp Buenos Aires Data.
Last active
February 2, 2018 17:49
-
-
Save ploscri/8759651 to your computer and use it in GitHub Desktop.
shp -> geojson -> topoJson
This file contains hidden or 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> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/topojson.v0.min.js"></script> | |
<style type="text/css"> | |
</style> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
//Width and height | |
var w = 900; | |
var h = 500; | |
//Define map projection | |
var projection = d3.geo.transverseMercator() | |
.center([0, -34.61]) | |
.rotate([58.38, 0]) | |
.scale((h * 56.5) / 0.2); | |
//Define path generator | |
var path = d3.geo.path() | |
.projection(projection); | |
//Create SVG element | |
var svg = d3.select("body") | |
.append("svg") | |
.attr("width", w) | |
.attr("height", h); | |
//Load in topojson data | |
d3.json("barriosTopo.json", function(error, topology) { | |
svg.selectAll("path") | |
.data(topojson.object(topology, topology.objects.barrios).geometries) | |
.enter() | |
.append("path") | |
.attr("d", path) | |
.style("stroke", "steelblue"); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment