Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
    
can you pls post which geojson and json file that you wanna merge? –  Aragon Nov 19 '12 at 8:54
    
Sure I can. This is the JSON-File global.mapit.mysociety.org/area/14455 And this is the GeoJSON global.mapit.mysociety.org/area/14455.geojson –  hoge6b01 Nov 19 '12 at 11:26

2 Answers 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.

share|improve this 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)

i hope it helps you...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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