I would like to write some functions in C to call from the Python console in QGIS. What is the easiest way to do this? Does there exist anything comparable to Matlab's MEX?

  • Is there a reason you want to go to C vs staying in Python? – Nathan W Jul 13 '16 at 10:05
  • Speed, of course! – Matt D. Jul 13 '16 at 12:35
  • What are you doing that requires that kind of speed? Have you done it in Python or using numpy already and speed tested it? – Nathan W Jul 13 '16 at 12:43
  • Well, it seems like being able to make C-based extensions to QGIS ought to be generally useful, as there are many tasks in GIS that are computationally intensive, and not all of them have been coded up for the general public yet. For example, if I want to resize a raster, but instead of using nearest-neighbor or quadratic/cubic interpolation, effectively taking the mean of pixels, I want to sum the pixels. This is necessary for resizing certain types of data (like population counts, for example), but there is no GDAL/SAGA/whatever function that can currently do it, to the best of my knowledge. – Matt D. Jul 13 '16 at 15:11
  • 1
    Have you considered Cython? – Nat Wilson Jul 16 '16 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.