August 2, 2026
The QGIS program - Writing my own plugin -- planning
Year ago I purchased sets of TOPO! CD maps for several
western states.
Arizona, California, Nevada, Utah, Colorado, and New Mexico.
I copied all of these to my hard drive with some minor
organization. Then I wrote a program in C called "gtopo"
that runs on linux and displays maps. I use it regularly.
The files are in /u1/topo on my machine.
Now that I am learning how to use QGIS, it occurs to me that
it would be fantastic to have a convenient way to pull this
data into QGIS.
QGIS and plugins
You have the choice of C++ or Python.
Python is generally recommended because the API is
more stable. C++ is definitely possible, but will
periodically require work as new QGIS versions come along.
Python can be used as a wrapper around C or C++ code.
Here is what I have learned from some searching:
The core software of QGIS is built with C++ and uses the Qt framework,
its internal object-oriented API requires C++ classes.
The C++ Plugin route
Pros: Direct compilation into machine code,
blazing-fast processing speed, and zero overhead between QGIS and your C code.
Cons: It is highly complex.
The QGIS C++ API lacks stable cross-version compatibility,
meaning you must rebuild your plugin for virtually every QGIS
sub-version update. You must also handle compiling separate
binaries for Windows, macOS, and Linux.
The Python with C Plugin route
You compile your C code into a shared library
(a .dll file on Windows or a .so file on Linux).
Then, use Python libraries like ctypes or cffi inside your
QGIS Python plugin to call the functions directly from that library.
Pros: Significantly easier setup.
Python plugins maintain better API stability between updates,
and you can quickly build user interfaces
using tools like Plugin Builder.
Cons: You still have to compile and distribute the specific
platform-dependent binary files alongside your python plugin.
The Python route
Here you do everything in Python.
This is the recommended route.
What I need to do is balance the advantages of working
in Python against the fact that I already have working C
code in my gtopo project. My bet is that this is the
best choice. I can use my C code as a guide to writing
python code to read my topo files.
A search "can I write a qgis plugin in python" gives plenty
of information.
Feedback? Questions?
Drop me a line!
Tom's Geology Info / tom@mmto.org