How to use the turf.reclass function in turf

To help you get started, we’ve selected a few turf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github morganherlocker / hail-data / index.js View on Github external
}

    year = 1955;
    while(year <= 2013){
        var translation = breaks[year.toString()];
        var translations = [
            [0, translation[0], 1],
            [translation[1], translation[2], 2],
            [translation[2], translation[3], 3],
            [translation[3], translation[4], 4],
            [translation[4], translation[5], 5],
            [translation[5], translation[6], 6],
            [translation[6], translation[7], 7],
            [translation[7], Infinity, 8]
        ];
        grid = turf.reclass(grid, year.toString(), year.toString()+'_class', translations);
        grid.features.forEach(function(cell){
            if(!cell.properties[year.toString()+'_class']) cell.properties[year.toString()+'_class'] = 0;
        })
        year++;
    }
    return grid;
}