Convert GML/GeoJSON to shapefile with QGIS

Quick tutorial on how not to get loss in the sea of spatial data format

 584 words  |   3-min read  |    spatial data, QGIS


2021-10-convert-spatial-data-qgis/export-layer.png

TL;DR

Use QGIS to import, convert and export spatial data that cannot be directly read into ArcGIS Pro.


The pain of getting correct spatial data file format

Sometimes, spatial data are not available in shapefile (.shp) format. And you may experience difficulties when importing those data to ArcGIS Pro. Dealing with non-shapefile or non-geodatabase format spatial data in ArcGIS Pro could be troublesome sometimes.

Examples are Large Tertiary Planning Unit (TPU) spatial data and Large Street Block Group (LSBG) spatial data available in the Hong Kong GeoData Store, which spatial vector data are only available in GML format.

large-tpu-geodata-store

Sorry sir, GML only

In these cases, a quick workaround is to convert those data to shapefile first. QGIS provides a FREE and OPEN-SOURCE software (with graphical user interface) to convert between various spatial data format.

But what is spatial data file format?

Files in your computer, in most cases, have specific file formats for software to understand how to read them. Taking audio file as an example, there are .mp3 / .flac / .alac / .m4a (and more) audio files. Specifying the file format allows iTunes or Windows Media Player to understand how to read the file and play the music for you.

In some cases, you need to convert your music file to another format. Say, you want to convert .flac to .alac in order to import the music to iTunes. And audio file format convertor softwares are available for you to convert between different audio file formats.

QGIS is offering the same kind of help here - instead of audio file format conversion, QGIS is offering its helping hand for spatial data format conversion.

There are more than 100 types of spatial data format across the ocean of GIS. You have experience in dealing with shapefile (.shp) and geodatabase (.gdb) in the current state. Yet there are also some common spatial data you will come across in the wild:

File ExtensionFull Name
.shpShapefile
.gdbGeodatabase
.geojsonGeoJSON
.gmlGeographic Markup Language
.gpkgGeoPackage
.kmlKeyhole Markup Language

How to convert spatial data format in QGIS

Step 0: Download and Install QGIS

Installer for Windows
  • QGIS is also available on Mac and Linux!

    download-qgis-mac

Installer for Mac
  • Install it according to the instructions! (Trust me, having both ArcGIS and QGIS installed is useful for spatial analysis.)

Step 1: Open a new project

  • Open QGIS, click the white paper icon on top left of the toolbar to create a new project

    create-new-project

  • A blank layout view will be create like below.

    new-project

Step 2: Add the spatial data file into QGIS

  • Drag the Large TPU GML file (or other non-shp data you found) from file explorer to the Layers panel (Same as Table of Contents in ArcGIS Pro)

    drag-into-qgis

Step 3: Export the file

  • Right Click the layer in Layers panel, then choose Export > Save Feature As…

    export-layer

  • Choose ESRI Shapefile as the Format

  • For File name, Indicate the folder you want to store the file and name your file.

  • Leave other options as default

    export-option

  • Click OK

A green bar appear will on top of the map frame after the export function runs successfully.

output-qgis

Check your directory to see if the spatial data is correctly exported. Remember that shapefile is a multi-file document including (but not limited to) files with extension of .shp, .shx and .dbf.

exported-shp


Note

Shapefile is an old data format and has a number of shortcomings. Switch to other formats if possible.

The Latest