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 http://converter.mygeodata.eu/ , but the GeoJSON it returned did not contain any actual geometry).

What is the best approach to convert GML into GeoJSON?

4 Answers 4


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.

  • 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? Jul 1, 2012 at 17:26
  • 2
    as per gis.stackexchange.com/a/11482/5850, you need GDAL 1.8.0 or above..what is your version?
    – vinayan
    Jul 2, 2012 at 1:08
  • 1
    @LarsGrammel try the latest version, gisinternals.com/sdk/…
    – vinayan
    Jul 2, 2012 at 1:25
  • I used the latest fwTools for Windows (2.4.7). Will try the latest version of GDAL as you suggested. Jul 2, 2012 at 2:06
  • GDAL 1.9.1 (included in the latest SDK) worked for me. Thanks! Jul 2, 2012 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.


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:


  • That example has nothing to do with GML to GeoJSON
    – g07kore
    Apr 27, 2017 at 8:11

You can use QGIS for it. Load the .gml file and export it in the format you want to.

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.