Hello I am working with a large geojson dataset, and I am trying to see if I can merge the coordinate values of each entry based on entries that share the same "User_ID".
My dataset look like this:
{
"geometry":{
"type":"Point",
"coordinates":[
-3.231658,
51.687026
]
},
"type":"Feature",
"properties":{
"User_ID":1002848324
}
},
{
"geometry":{
"type":"Point",
"coordinates":[
-3.231659,
51.687016
]
},
"type":"Feature",
"properties":{
"User_ID":1002848324
}
}
I have tried to merge the entries using the method shown in mwarren's answer, url: "https://stackoverflow.com/questions/29244116/merge-geojson-based-on-unique-id".
Yet this comes with the small problem that "attr" is seen as an "Unexpected Identifier" when I try to run a test.
My test of the code so far is as follows:
features.map(function(feature){
var matchedArray = features2.filter(function(feature2){
return feature2.User_ID === feature.User_ID;
});
if(matchedArray && matchedArray[0]){
for(var attr in matchedArray[0].properties){
feature.properties[attr] = matchedArray[0].properties[attr];
}
}
});
The desired result should look something like this:
{
"geometry":{
"type":"Point",
"coordinates":[
-3.231658,
51.687026
], [
-3.231659,
51.687016
]
},
"type":"Feature",
"properties":{
"User_ID":1002848324
}
Any help will be greatly appreciated.