I have a quick question please about converting JSON/GeoJSON files.

I'm trying to convert some JSON files into something I know how to work with (shapefile, R objects or PostGIS). I'm afraid I have no experience with JSON.

I've tried converting them to shapefiles using ogr2ogr, readOGR in R, and FME. I've tried converting them and uploading them to a PostGIS database using FME. And I've tried converting them to R objects using the rjson package. Nothing works.

ogrinfo can't read them and the couple of online JSON/GeoJSON validation tools I've tried say they are not valid JSON files?

Would someone who understands JSON/GeoJSON mind taking a very quick look at one of the files please, and tell me if they're OK? If they're fine, that's great, I can go away and try and work it out. If not, I can save myself a little head scratching. I'm sure there's probably nothing wrong with them.

Here's a link to one of the files in my Google Drive: Opendata Scotland JSON File


1 Answer 1


To convert TopoJSON files to Shapefiles using ogr2ogr you'll need to install the geojson-cli package for Node.js using the Node Package Manager (NPM). You can follow the instructions below or read this article on installing both.

# If you need to install Node and NPM...
wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
tar -xzvf node-v0.10.24.tar.gz && rm node-v0.10.24.tar.gz && cd node-v0.10.24
sudo make
sudo make install

# For installing NPM...
wget https://npmjs.org/install.sh
source install.sh

# Finally, install the geojson-cli
sudo npm install -g geojson

With the geojson-cli installed, you can convert your TopoJSON back into GeoJSON, which can then be converted to a Shapefile using ogr2ogr.

# Automatically makes a file with ".topo" removed in filename
geojson my.topo.json
ogr2ogr -f "ESRI Shapefile" my.shp my.json

Alternatively, you can convert your TopoJSON to GeoJSON and back again using this handy web client.

  • Thanks ever so much for taking the time to reply. I'm having a few issues getting everything to work, but you've put me on the right track. Mar 10, 2014 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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