Why convert GML to GEOJSON?
GML (Geography Markup Language) is an XML-based OGC standard for geographic features introduced in 2000. GeoJSON stores the same features as JSON and is the standard input for web mapping libraries such as Leaflet and Mapbox. Web tools rarely read .gml directly, making conversion the practical step before publishing geographic data on a map.
How to convert GML to GEOJSON
GDAL/OGR (ogr2ogr) OPEN-SOURCE
Run ogr2ogr -f GeoJSON out.geojson in.gml in a terminal; add -t_srs EPSG:4326 to reproject to WGS 84 if the source CRS is not already geographic.
QGIS FREE
Add the .gml as a vector layer, right-click it in the Layers panel, choose Export > Save Features As, set format to GeoJSON, and set CRS to EPSG:4326.
About these formats
A .gml file is a Geography Markup Language file - an XML format defined by the Open Geospatial Consortium (OGC) for storing map and GIS data such as points, lines, polygons, and coordinate…
Open .GML details →A GEOJSON file stores geographic features - points, lines, and polygons with their attributes - as plain JSON text, and it is the standard format for web mapping. To view it on a map…
Open .GEOJSON details →Quality & what to watch
- GeoJSON (RFC 7946) requires WGS 84 geographic coordinates; always reproject during export if the source CRS is a local projected system.
- Feature attributes and geometry (points, lines, polygons) carry over intact to the GeoJSON
propertiesand geometry objects. - Both formats are text-based; the output
.geojsonfile is similar in size to or slightly smaller than the source.gml.
Frequently asked questions
Does QGIS include GDAL?
ogr2ogr command-line tool.Will mixed geometry types in a GML file cause problems?
Why does my GeoJSON display incorrectly on a web map?
-t_srs EPSG:4326 in ogr2ogr or select EPSG:4326 in the QGIS export dialog.