I have a GeoJSON file of the country of Haiti with the administrative boundaries for communes (i.e. counties). Here is the file:

https://rawgit.com/mattbowlby/bf5243ab097e50eb8864/raw/46818c96bc49629681238d5302d597456227c040/haiti_communes.geo.json

That file has a few properties, for example:

( "properties": {
        "id_com": 112,
        "commune": "Delmas",
        "id_dept": 1,
        "dept": "West Department",
        "shape_leng": 0.242799419022,
        "latitude": 18.5543057016,
        "longitude": -72.297644435,
        "shape_le_1": 0.242799419022,
        "shape_area": 0.00222841371629

Now, I want to be able to add a number of new properties, such as area, population and other things. I have 141 different communes and do not want to enter this information manually. Is there a way to work with a GeoJSON file and add the properties, such as with a spreadsheet or other format? Ideally I would have it in a spreadsheet and add in the new properties as columns.

up vote 3 down vote accepted

I would download and install QGIS, and then open the geojson file by clicking Add vector layer button:

enter image description here

After that you should be able to see you geojson file in QGIS:

enter image description here

And right click the layer's name in the left hand layer list, and click "Properties"; then go to the "Joins" tab, and click the green plus icon on the left bottom corner to open "Add vector join":

enter image description here

Join the table with the fields you would like to append to your geojson file; then right click layer's name in the left hand layer list, and click "Save As..." to save the geojson file into a new file and you should have what you need. And make sure you specify the output format as "GeoJSON":

enter image description here

Hope this helps, thanks.

  • I succeeded in installing QGIS and loading the GeoJSON file as in your example. However, when I go to Properties -> Joins for that layer and select "Add vector join", there are no join layers or join fields for me to select. How do I get my new data in and added as properties to the file? For example, I have a spreadsheet listing population, area and other values to be added to each commune. – mattbowlby Aug 5 '14 at 18:03
  • You need to add the spreadsheet to QGIS first as well. So I would save the spreadsheet as a CSV file, and then use "Add vector layer" to add the CSV file to the layer list, then you should be able to see the table when you open "Add vector join". If you can't get that work, maybe you can share the spreadsheet somewhere (like google doc) and I can edit my answer by adding some more screenshots. – Vanni Zhang Aug 6 '14 at 0:57
  • Yes - that worked perfectly. It added the properties just as I wanted. Thank you for you help. I truly appreciate it. A very detailed answer with nice screenshots. – mattbowlby Aug 6 '14 at 1:19

In case you work with d3 (as your tag suggests) here is an alternative using topojson.

For a tsv file "attributes.tsv" in the following format:

id  attribute
112 A
114 B
123 C
211 D
442 E
343 F
...

Convert to topojson:

topojson -o topojson.json haiti_communes.geo.json -p

Join:

topojson -o final.json -e attributes.tsv --id-property=+id_com,+id -p -- topojson.json

hat tip

  • I will try this today and see if I can get it to work. – mattbowlby Aug 5 '14 at 18:05

Another option would be to use geojson.io Just upload your geojson file and add a column, and do your edits.

enter image description here

Once you are satisfied with your edits, you can just download the resulting geojson file

enter image description here

Good luck!

  • This works well too. Thanks! – mattbowlby Dec 7 '14 at 14:53
  • @mattbowlby You're welcome! Well enough for an upvote? ;-) – R.K. Dec 7 '14 at 14:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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