I have been able to load a GeoJSON file into QGIS by simply clicking "Add Vector Layer", and selecting my file to load.

Now I'm using the qgis.core Python package, and I'm trying to load the GeoJSON file as a layer. I'm following instructions from the QGIS Python Cookbook - Loading Layers section; but I can't find how to specify that I'm loading a GeoJSON file.

I've tried:




to no avail. Any advice on what I could do?

1 Answer 1


Use the OGR library, there is a complete list of supported filetypes.

From the QGIS Python Cookbook - Loading Layers:

OGR library (shapefiles and many other file formats) — data source is the path to the file

vlayer = QgsVectorLayer("my_geo.json","mygeojson","ogr")

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.