How To Convert A Shapefile To A GeoJSON File Using QGIS

…using instructions in Yuiry Czoli’s Gist

Evan SooHoo
2 min readAug 1, 2024
The result of plugging the QIS-converted geojson file into geojson.io

I recently came across some map data that was only available to download as a shapefile — I wanted to visualize it using the ArcGIS JavaScript API, as I don’t own a license to ArcGIS.

For this example, I will be using the publicly available borders of LA county, which is what Esri uses in their own example. I will hopefully be going to this county in a week, for someone’s wedding.

The code example by Esri is here, and…it works. I was able to upload the sample drp_county_boundary shape file zip, then see that visualized as a feature layer.

So…we’re done, right?

Maybe, but if you look at the source code you will notice that the conversion took place using arcgis.com as a portal. This has a few limitations:

  • If the file is too large, arcgis.com itself can reject it
  • Hypothetically speaking, the shapefile data you are working with may not be public. If your customer has given you something proprietary or non-public, like the location of a building site, then you probably do not want to upload that to the arcgis server

The Czoli Way

In this Gist, Czoli shows how to do this in QGIS. The process looks quite involved, but I found it to be considerably easier than trying to use the open source shapefile-js npm package.

Open QGIS, select “add layer,” “add vector layer,” and browse to either the shp file or the zip that contains the shp file.

QGIS is already able to make sense of this shapefile.

Right click on the layer in the bottom left, and export as a geojson file. Use ESPG 4326.

You will obtain a geojson file, which you can test in geojson.io.

I see there’s a conversion site online, but even for this toy data it didn’t work for me. The data was not in 4326, so geojson.io just errored out.

Closing Thoughts

There are none, that’s it.

--

--

Evan SooHoo
Evan SooHoo

Written by Evan SooHoo

I never use paywalls (anymore) because I would get stuck behind them.

No responses yet