Finding good playgrounds
In this example, we'll fetch the greenspace data and filter it to show only greenspaces with playgrounds that our surveyors rated "Very Satisfied" or "Satisfied".
- First, we fetch the data into greenspaces. (We use the async-get-json module to do this.)
- We filter this to only include features where an assessor answered "Yes" to field R1P. This goes into playgrounds.
- Then we filter the playgrounds to only include those where an assessor answered "Very_Satisfied" or "Satisfied" to field NESTLIKERT.
- RunKit automatically visualises the result as features on a map.
Click "run" to see the result (you'll need to wait a few seconds for it to show).
var getJSON = require("async-get-json"); var greenspaces = await getJSON("https://greenspacehack.com/data/full.geojson"); var playgrounds = greenspaces.features.filter(feature => (feature.properties['R1P'] || '').includes("Yes")); var good_playgrounds = playgrounds.filter(feature => (feature.properties['NESTLIKERT'] || '').includes("Very_Satisfied") || (feature.properties['NESTLIKERT'] || '').includes("Satisfied"));
You can see an expanded version of this on RunKit.