GeoJSON and JSON Merging – How to Join GeoJSON and JSON

geojsonjson

I want OSM administrative boundaries from http://global.mapit.mysociety.org/area/14455.html.
I can get the geodata in different formats there, but the attribute data always is a separate JSON file. I want them both in just one file, or to be able to merge the information.

I haven't found a solution to merge the GeoJSON.

What's the workflow to get the two files joined and saved as a shapefile, for example?

Best Answer

i dont know where you want to merge but you can do it with python as following code.

merged = {
   firstObj : {"parent_area": null, "generation_high": 1, "all_names": {"default": ["OSM Default", "South Georgia"]}, "id": 14455, "codes": {"osm_rel": "1983629"}, "name": "South Georgia", "country": "G", "type_name": "OSM Administrative Boundary Level 3", "generation_low": 1, "country_name": "Global", "type": "O03"},    
   secondObj : { "type": "MultiPolygon", "coordinates": [ [ [ [ -37.652271, -54.065565 ], [ -37.649751, -54.066685 ], [ -37.644852, -54.065705 ], [ -37.644572, -54.064725 ], [ -37.652271, -54.065565 ] ] ], [ [ [ -38.297102, -53.993427 ], [ -38.295513, -53.992544 ], [ -38.294201, -53.992191 ], [ -38.294226, -53.991661 ], [ -38.293848, -53.991661 ] ] ] ] }
};

Code:

import json

merged = { 'firstObj ' : obj1, 'secondObj' : obj2 }
json.dumps(merged)