I am struggling to render a geoJSON file using d3 because I am having trouble targeting the correct features for projection.
Instead of working with the typical us.json file used in many d3 examples, my current map focuses on United States "Commuting Zones" (CZ's) rather than land, states, or counties.
In my usual process, I call
topojson.feature(us, us.objects.states)
to display the correct layer. However, the file I'm currently working with is not organized into objects and does not have multiple layers. Here is an excerpt from the geoJSON file:
{"type":"FeatureCollection","bbox":[-120.30602148510043,6.667736880597216,-70.95829310710806,34.46308750538215],"features":[{"type":"Feature","geometry":{"type":"Polygon","coordinates":[[[-83.802805983004,22.64602264051764],[-83.8080569412408,22.638128812605782],
Below is the code I am using, which is not successfully rendering the map:
d3.json("CZ90.zip.geojson", function(error, us) {
if (error) throw error;
d3.select("svg").append("path")
.datum(topojson.feature(us, us.CZ90))
.attr("d", d3.geo.path());
});
Since there are no objects defined in the file, I omitted the ".object". When I view the file in Mapshaper, it renders correctly with a layer titled "CZ90", leading me to try "us.CZ90" instead of "us.objects.states"
I understand that I may be using "topojson.feature" instead of something geoJSON specific, but I have been unsuccessful in converting the file to topoJSON in Mapshaper without losing projection information.
What is the right way to target this layer in the .datum call?
This issue would be resolved if I could find a topoJSON file similar to us.json that includes a commuting zones layer!