This is a 12.9MB shapefile! If your browser supports streaming fetch, it will start being displayed even before it has finished downloading. Streaming in-browser parsing is new in shapefile 0.5.
-
-
Save ferdasonmez/238340f91c759477990bd8cffcd1512c to your computer and use it in GitHub Desktop.
Streaming Shapefile
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: gpl-3.0 | |
height: 600 |
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> | |
<canvas width="960" height="600"></canvas> | |
<script src="https://d3js.org/d3-array.v1.min.js"></script> | |
<script src="https://d3js.org/d3-geo.v1.min.js"></script> | |
<script src="https://d3js.org/d3-geo-projection.v1.min.js"></script> | |
<script src="https://unpkg.com/shapefile@0.5"></script> | |
<script> | |
var canvas = document.querySelector("canvas"), | |
context = canvas.getContext("2d"); | |
var path = d3.geoPath() | |
.context(context) | |
.projection(d3.geoAlbersUsa() | |
.scale(1285) | |
.translate([canvas.width / 2, canvas.height / 2])); | |
context.lineWidth = 0.5; | |
shapefile.open("https://cdn.rawgit.com/matplotlib/basemap/master/lib/mpl_toolkits/basemap/data/UScounties.shp", null) | |
.then(function(source) { | |
return source.read().then(function next(result) { | |
if (result.done) return; | |
context.beginPath(); | |
path(result.value); | |
context.stroke(); | |
return source.read().then(next); | |
}); | |
}) | |
.catch(function(error) { | |
console.error(error.stack); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment