You can get raw adjacency information as a side-effect of the topojson.mesh
and topojson.meshArcs
functions (assuming you like JavaScript). The optional third parameter to those is a function that will be called (perhaps repeatedly) for adjacent geometries. Here's some nodejs pseudo-code:
var topojson = require('topojson');
var fs = require('fs');
var inputTopology = JSON.parse(fs.readFileSync( ... ));
var objectOfInterest = inputTopology.objects.alldistricts;
topojson.meshArcs(inputTopology, objectOfInterest, function(distA, distB) {
console.log(distA.properties.Name + " and " +
distB.properties.Name + " are adjacent!");
});
It doesn't produce a real matrix, but that could be done with a little bit of extra code inside that function.
And note that the function will be called for each arc in the topology, so you'll get calls where distA
and distB
are the same object (when an arc is "exterior"), and you'll potentially get multiple calls for the same distA
and distB
if one of their shared edges is made up of multiple arcs.