I've been attempting to create a TopoJson file with consolidated layer data containing, among other layers, U.S. States, Counties, and Congressional Districts.
Original .shp shapefiles come from the Census Bureau's Cartographic Boundary Files.
These were converted to GeoJson via ogr2ogr.
Then combined into TopoJson format via the node server side library, with quantization of 1e7 and retain-proportion of 0.15. Up to this point there is no indication of any problem.
I view the final topojson file using mapshaper and things seem to look OK:
But, when attempting to render with the topojson client library and D3.geo.path(), I encounter some strange paths in the congressionalDist layer: (notice the large rectangular paths around the continental US, AK, and HI)
A working version of the page can be found here: http://jsl6906.net/D3/topojson_problem/map/
A couple of relevant notes:
- If I change my topojson generation script to remove simplification, the paths then seem to show correctly via the same d3.js page
- If I only keep the congressionalDist layer when creating the topojson, the paths then seem to show correctly via the same d3.js page:
After attempting as much troubleshooting as I've been able to handle, I figured I would ask someone here to see if someone has experienced any similar issues. Thanks for any help.
d3.geo.bounds(cds[84])
results in `[[-180, -90], [180, 90]]' which seems to be incorrect. I do not know why this happens though. – Jan van der Laanid
property of the data bound to the offending rectangles ends inZZ
, whereas all other objects have an id ending with two numbers. The id's responsible are: 09ZZ, 17ZZ, and 26ZZ. For example, try the following:d3.selectAll(d3.selectAll('.cd')[0].filter(function(d) { return d3.select(d).attr('id').slice(-2) === 'ZZ' })).style('stroke', 'red')
and you will notice that only those rectangles are colored red. – jshanleyZZ
is the code given to "undefined" congressional districts. I'm not exactly sure what this means, but you can see it occurring in this dataset under the column CD113FP, wherever the NAMELSAD column contains "Congressional Districts not defined". Also there is a reference to removing such districts when running ogr2ogr in this file which is part ofus-atlas
– jshanley