forked from alpha-beta-soup's block: d3 map experiment with NZTM [UNLISTED]
Last active
May 21, 2017 09:12
Star
You must be signed in to star a gist
d3 map experiment with NZTM [UNLISTED]
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
license: mit |
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> | |
.land { | |
fill: #ddd; | |
} | |
.boundary { | |
fill: none; | |
stroke: #999; | |
} | |
</style> | |
<svg width="960" height="800"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v2.min.js"></script> | |
<script> | |
var svg = d3.select("svg"), | |
width = +svg.attr("width"), | |
height = +svg.attr("height"); | |
// function scale (scaleFactor, width, height) { | |
// return d3.geoTransform({ | |
// point: function(x, y) { | |
// this.stream.point( (x - width/2) * scaleFactor + width/2 , (y - height/2) * scaleFactor + height/2); | |
// } | |
// }); | |
// } | |
var p = d3.geoIdentity().reflectY(true), | |
path = d3.geoPath().projection(p);//scale(1, width, height)) | |
d3.json("wards-simple-topo.json", function(error, nz) { | |
if (error) throw error; | |
// console.log(nz) | |
// nz.transform.scale = [0,0];//undefined; | |
// nz.transform.translate = [0,0]; | |
var wards = topojson.feature(nz, nz.objects.wards); | |
p.fitExtent([[0,0],[960,500]], wards) | |
svg.append("path") | |
.datum(wards) | |
.attr("class", "land") | |
.attr("d", path); | |
// svg.append("path") | |
// .datum(topojson.mesh(nz, nz.objects.wards, function(a, b) { return a !== b; })) | |
// .attr("class", "boundary") | |
// .attr("d", path); | |
}); | |
</script> |
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
build/ESRI_Census_Based_2013_NZTM.zip: | |
mkdir -p $(dir $@) | |
curl -o $@ http://www3.stats.govt.nz/digitalboundaries/census/$(notdir $@) | |
build/ESRI_Census_Based_2013_NZTM.shp: build/ESRI_Census_Based_2013_NZTM.zip | |
unzip -od $(dir $@) $< | |
touch $@ | |
build/wards.geojson: build/ESRI\ shapefile\ Output/2013\ Digital\ Boundaries\ Generalised\ Clipped/WARD2013_GV_Clipped.shp | |
ogr2ogr -f GeoJSON build/wards.geojson build/ESRI\ shapefile\ Output/2013\ Digital\ Boundaries\ Generalised\ Clipped/WARD2013_GV_Clipped.shp -s_srs EPSG:2193 -t_srs EPSG:2193 | |
build/wards.json: build/wards.geojson | |
node_modules/topojson/node_modules/topojson-server/bin/geo2topo \ | |
-o $@ \ | |
wards=$< | |
build/wards-simple-topo.json: build/wards.json | |
node_modules/topojson/node_modules/topojson-client/bin/topoquantize 1e4 \ | |
< $< \ | |
> build/wards-simple-topo.json |
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
{ | |
"name": "d3-bubble-map", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"devDependencies": { | |
"gistup": "^0.1.3", | |
"http-server": "^0.10.0" | |
}, | |
"dependencies": { | |
"topojson": "^3.0.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment