UPDATE: Solved, sort of … I downloaded the file afresh and tried feeding it through ogr2ogr and topojson again … and wouldn't you know … after a while it worked. I think I was possibly not setting an id property. This was a big help: https://stackoverflow.com/questions/14565963/topojson-for-congressional-districts

ORIGINAL POST: So, for the friends who have used Tiger shapefiles, clue me in on my mistake here?

I suspect it's something with wrong projection or wrong conversion from shapefiles? The .xml suggests the projection is WGS_1984_Web_Mercator_Auxiliary_Sphere

I converted with ogr2ogr then to topojson, a la the Mike Bostock canonical example: http://bost.ocks.org/mike/map/ (FWIW, I also tried with mapshaper.org and also got a bunch of shards.)

UPDATE: I wasn't clear abt mapshaper.org -- it displays this file perfectly online, but when I download topo from it, yea, I get shards.

This should be a map of two Georgia counties, an area maybe 100 miles across. The shapefile came from U.S. Census Tiger.

I got another shapefile of the same area from our state mapping agency and it mapped perfectly.

Any ideas?

UPDATE: here is the shapefile I've been using: https://www.dropbox.com/s/kux63jdo66h87uk/reference_map_shape.zip?dl=0

d3.json("050_002.json", function(error, counties) {
  if (error) return console.error(error);
  console.log("ok counties:", counties)

  var projection = d3.geo.mercator()
    .rotate([84.2, -33.9, 0]);

var path = d3.geo.path()

  .datum(topojson.feature(counties, counties.objects['050_00']))
  .attr("d", path)

enter image description here

  • Can you post the Tiger shape file you have been working with? – cengel Oct 1 '14 at 22:01

Reproject from Web Mercator, for example to WGS84

ogr2ogr -f GeoJson 050_00wgs84.gjson 050_00.shp -s_srs EPSG:3857 -t_srs EPSG:4326
topojson --id-property=GEO_ID -o 050_00wgs84.json -- 050_00wgs84.gjson


var width = 800,
height = 800;

var svg = d3.select("body").append("svg")
 .attr("width", width)
 .attr("height", height);

d3.json("050_00wgs84.json", function(error, counties) {

  var projection = d3.geo.mercator()
    .center([-84.5, 34])

  var path = d3.geo.path()

    .datum(topojson.feature(counties, counties.objects['050_00wgs84']))
    .attr("d", path)

enter image description here

| improve this answer | |
  • I wish I had enough points to upvote you! Thanks! – Maggie Oct 2 '14 at 18:18
  • 1
    @Maggie, great to hear this was helpful. I just upvoted your question, you should have enough points now. Could you also accept this as answer? – cengel Oct 3 '14 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.