5

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?

2

You can simply use this python script to merge the jsons together.

Then, it's your personal preference for how to convert it into a shapefile.

You can go with ogr2ogr like:

ogr2ogr -f "ESRI Shapefile" output.shp raw.geojson

or if you're more comfortable with a GUI, you can open the json in qgis and save as a shapefile.

6

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.