Is it possible to merge multiple GeoJSON objects using javascript built-in functions? If not, how can I do this on the fly?
I tried geoJSON1 = geoJSON1.concat(geoJSON2) as per suggestions for JSON (e.g. here), which returns geoJSON1.concat is not a function. The GeoJSONs are point features and are valid GeoJSON objects.
This is probably a simple question with "no" for an answer, but I haven't been able to find a conclusive answer.
Example GeoJSONs:
GeoJSON1 = { "type" : "FeatureCollection",
"features" : [
{ "type" : "Feature",
"id" : 1,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.6165333","34.35935"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "0", "time" : "19:26:58", "date" : "2005-08-26"}
},
{ "type" : "Feature",
"id" : 2,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.6165167","34.35935"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "2", "time" : "19:27:00", "date" : "2005-08-26"}
}
]
}
GeoJSON2 = { "type" : "FeatureCollection",
"features" : [
{ "type" : "Feature",
"id" : 27,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.61635","34.3593833"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "55", "time" : "19:27:53", "date" : "2005-08-26"}
},
{ "type" : "Feature",
"id" : 28,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.6163333","34.3594"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "56", "time" : "19:27:54", "date" : "2005-08-26"}
}
]
}
Desired result (single GeoJSON with all the features of the originals):
newGeoJSON = { "type" : "FeatureCollection",
"features" : [
{ "type" : "Feature",
"id" : 1,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.6165333","34.35935"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "0", "time" : "19:26:58", "date" : "2005-08-26"}
},
{ "type" : "Feature",
"id" : 2,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.6165167","34.35935"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "2", "time" : "19:27:00", "date" : "2005-08-26"}
},
{ "type" : "Feature",
"id" : 27,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.61635","34.3593833"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "55", "time" : "19:27:53", "date" : "2005-08-26"}
},
{ "type" : "Feature",
"id" : 28,
"geometry" : {
"type" : "Point",
"coordinates" : ["-119.6163333","34.3594"]},
"properties" : { "video" : "S105SC_Tape13o.noaudio.mpg", "video_second" : "56", "time" : "19:27:54", "date" : "2005-08-26"}
}
]
}
concatmethod doesn't work? @kristaps I added some simple examples of input and result.