In regards to:

I am running into an error in displaying my map. The error: TypeError: counties[i].properties is undefined

We need to examine both the referenced world topojson and US topojson.

In the world topojson, the geometries are defined like this:


There is a properties attribute to each geometry.

In the US topojson you reference, the geometries are defined like this:


There is no properties attribute assigned to each geometry. So, when you call for the properties of a geometry, it'll return undefined.

So instead of using counties[i], you might find more success with counties[i].id.

It may also be worth noting, if you are comparing examples, that the conversion from topojson to geojson (topojson.feature(us, us.objects.counties).features) will modify the structure of the data as well:

d3.json("//",function(error,us) {
  console.log("Number of county geometries:");
  console.log("Example county id:");
<script src=""></script>
<script src=""></script>

d3.json("//",function(error,us) {
  var geojson = topojson.feature(us, us.objects.counties).features;
  console.log("Number of features");
  console.log("Example county ID");
<script src=""></script>
<script src=""></script>

Related Query

More Query from same tag