Joining GeoJSON to another GeoJSON

Viewed 186

I have some geographic boundaries that I have a GeoJSON endpoint for.

I also have some variables that are stored at a separate GeoJSON endpoint which does not have coordinates, but does have the variable that I want to later thematically style a map with later on with D3. This is updated weekly.

There is a common ID in both responses called lga_name (Local Government Area Name) which I am trying to join on. There appear to be plenty of examples on how to join GeoJSON with a CSV, but not GeoJSON with GeoJSON.

I have had a stab at trying to put together an app, but still struggling with the join.

// Load LGAs from ArcGIS Online (The GeoJSON with geoms)
d3.json("the url to the Geoms", function(error, data) {

// Load Crash Stats from ArcGIS Online (the total persons involved, summarised down to LGA names)
d3.json("the url to the table", function(error, data2) {

        var lga = data.features;
        var crashStats = data2.features;

        // Not working
        var joined =  lga.forEach(function(item) {
            item.properties.LGA_NAME = crashStats[item.properties.lga_name];
        });

Can anyone give me some pointers to help get me moving? Just trying to learn some more about D3 and Javascript in general.

1 Answers
Related