US Road Map (data from natural earth).
Last active
December 16, 2021 16:22
-
-
Save bricedev/96d2113bd29f60780223 to your computer and use it in GitHub Desktop.
US Road Map
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> | |
.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('-'); }); | |
}); | |
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
topojson
-o usroads.json
--id-property sov_a3
--properties type
--
usa.json
roads.json
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment