Built with blockbuilder.org
Last active
November 4, 2015 07:24
-
-
Save biovisualize/583d18e90c37e5bf79d6 to your computer and use it in GitHub Desktop.
antimeridian cutting problem
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> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<style> | |
</style> | |
</head> | |
<body> | |
<script> | |
// this gepjson is supposed to look like this | |
// http://bl.ocks.org/d/ec4cebc0afcf170091b2 | |
// http://geojson.io/#id=gist:biovisualize/e1138c4419665f0a1d2b&map=2/20.0/0.0 | |
var polygonData = { | |
"type": "Feature", | |
"geometry": { | |
"type": "Polygon", | |
"coordinates": [ | |
[ | |
[ -100, -20 ], | |
[ -100, 20 ], | |
[ 100, 20 ], | |
[ 100, -20 ], | |
[ -100, -20 ] | |
] | |
] | |
}, | |
"properties": {} | |
}; | |
var width = 1000; | |
var height = 500; | |
var projection = d3.geo.equirectangular() | |
.scale(100) | |
.translate([width / 2, height / 2]) | |
.rotate([0, 0]) | |
.center([0, 0]) | |
.precision(0); | |
var path = d3.geo.path() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr({ | |
width: width, | |
height: height | |
}); | |
svg.append('path') | |
.datum(polygonData) | |
.attr({ | |
d: path, | |
fill: 'orange', | |
opacity: 0.5 | |
}); | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment