block by bricedev 96d2113bd29f60780223

US Road Map

Full Screen

US Road Map (data from natural earth).

index.html

<!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>

makefile.md

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