Skip to main content
4 of 5
deleted 16 characters in body
ThomasG77
  • 31.2k
  • 1
  • 55
  • 95

Because it's a "oneshot", you can do it manually (also possible running via Node)

Open a JavaScript console in your browser.

You need to loop to get an array of array of Feature (because each FeatureCollection have one or more Feature)

Then, you will use the flatten function to transform the array of array into an array (a recursive function borrowed from http://stackoverflow.com/a/15030117)

The full code is below (except the file content, not complete to keep things readable)

// Copy/paste the text from you source https://raw.githubusercontent.com/RitterLean/Geojson/master/geofile.json 
content = {
"points": [{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "coordinates": [41.9773865, 36.3372536],
            "type": "Point"
        },
        "properties": {
            "attacks": 1,
            "location": "Sinjar",
            "date": "2015-10-16"
        }
    }, {
        "type": "Feature",
        "geometry": {
            "coordinates": [43.4873886, 34.9301605],
            "type": "Point"
        },
        "properties": {
            "attacks": 2,
            "location": "Baiji",
            "date": "2015-10-16"
        }
    }, {
    ...
    // Be careful, incomplete because shortened for illustration 

intermediate_result = content['points'].map(function(el){
    return el.features;
});

function flatten(arr) {
  return arr.reduce(function (flat, toFlatten) {
    return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
  }, []);
};

geojson_output = {
        "type": "FeatureCollection",
        "features": flatten(intermediate_result)
}
// Transform the object to a string you can paste into a file
console.log(JSON.stringify(geojson_output));

The result can be seen at http://geojson.io/#id=gist:anonymous/da10ab9afc9a5941ba66&map=4/19.48/22.32

You will see that some results have wrong coordinates (0, 0). It's due to the original content.

From this demo, you can also export to GeoJSON.

ThomasG77
  • 31.2k
  • 1
  • 55
  • 95