US Road Map (data from natural earth).
Last active
August 29, 2015 14:25
-
-
Save bricedev/8820cc012f2b8309523c to your computer and use it in GitHub Desktop.
US Road Map II
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> | |
body { | |
font: 10px sans-serif; | |
} | |
.roads { | |
fill: none; | |
stroke-linejoin: round; | |
stroke-linecap: round; | |
} | |
.major-highway { stroke: #525252; stroke-width: 1.5px; } | |
.secondary-highway { stroke: #737373; } | |
.road { stroke: #bdbdbd; } | |
.beltway { stroke: #737373; } | |
.ferry-route { stroke: #4393c3; stroke-width: 1.5px; } | |
</style> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.19/topojson.min.js"></script> | |
<script> | |
var width = 960, | |
height = 600; | |
var projection = d3.geo.albersUsa() | |
.scale(1100) | |
.translate([width / 2, height / 2]); | |
var path = d3.geo.path() | |
.projection(projection); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.json("usroads.json", function(error, usroads) { | |
if (error) throw error; | |
svg.append("g") | |
.selectAll("path") | |
.data(topojson.feature(usroads, usroads.objects.usa).features) | |
.enter().append("path") | |
.attr("d", path) | |
.style("fill","none") | |
.style("stroke","#252525") | |
.style("stroke-width",1); | |
svg.append("g") | |
.selectAll("path") | |
.data(topojson.feature(usroads, usroads.objects.roads).features) | |
.enter().append("path") | |
.attr("d", path) | |
.attr("class",function(d) { return "roads " + d.properties.type.toLowerCase().split(' ').join('-'); }); | |
var places = svg.append("g"); | |
places.selectAll("path") | |
.data(topojson.feature(usroads, usroads.objects.places).features) | |
.enter().append("path") | |
.attr("d", path.pointRadius(4.5)) | |
.style("fill","#252525") | |
.style("stroke","#fff") | |
.style("stroke-width",1); | |
places.selectAll("text") | |
.data(topojson.feature(usroads, usroads.objects.places).features) | |
.enter().append("text") | |
.attr("transform", function(d) { return "translate(" + projection(d.geometry.coordinates) + ")"; }) | |
.attr("dy", ".35em") | |
.attr("dx", ".35em") | |
.style("font-size","15px") | |
.style("font-weight","bold") | |
.style("text-shadow", "0px 0px 2px #fff") | |
.text(function(d) { return d.properties.name; }); | |
}); | |
d3.select(self.frameElement).style("height", height + "px"); | |
</script> |
ogr2ogr
-f GeoJSON
-where "ADM0_A3 IN ('USA')"
usa.json
ne_10m_admin_0_countries.shp
ogr2ogr
-f GeoJSON
-where "sov_a3 IN ('USA')"
roads.json
ne_10m_roads.shp
ogr2ogr
-f GeoJSON
-where "ADM0_A3 = 'USA' AND SCALERANK < 3"
places.json
ne_10m_populated_places.shp
topojson
-o usroads.json
--id-property sov_a3
--properties type
--properties name
--
usa.json
roads.json
places.json
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment