Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have downloaded a GML file from Statistics Canada and would like to convert it into GeoJSON to use parts of it in a D3 visualization on the web. However, I did not find a converter that would do that for me (I tried , but the GeoJSON it returned did not contain any actual geometry).

What is the best approach to convert GML into GeoJSON?

share|improve this question
up vote 14 down vote accepted

You Can use ogr2ogr. Simplest to install it would be to download fwTools.

the following command will do

ogr2ogr -f "GeoJSON" E:\lakes.geojson e:\lakes.gml

Else if you have QuantumGIS, you can add your GML layer to map and by Right-Clicking the Layer, Select Save As to GeoJSON format.

share|improve this answer
Thanks! I just tried it & I got "ERROR 1: Unrecognized geometry type <Surface>." - does this mean that there a features in GML that cannot easily be converted to GeoJSON? – Lars Grammel Jul 1 '12 at 17:26
as per, you need GDAL 1.8.0 or above..what is your version? – vinayan Jul 2 '12 at 1:08
@LarsGrammel try the latest version,… – vinayan Jul 2 '12 at 1:25
I used the latest fwTools for Windows (2.4.7). Will try the latest version of GDAL as you suggested. – Lars Grammel Jul 2 '12 at 2:06
GDAL 1.9.1 (included in the latest SDK) worked for me. Thanks! – Lars Grammel Jul 2 '12 at 2:17

As vinayan said, ogr2ogr would be a good solution, but a handy way I've used in the past to quickly convert vector formats it to use this existing OpenLayers example:

Just draw your features or paste the data and hit add feature.

share|improve this answer

If you have R Studio (it's a free software), you can use the converter located here to easily convert large GML files to GeoJSON:

share|improve this answer

Your Answer


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.