Upcoming fun in QGIS 2.8: Define your own Python Functions

Feb 10, 2015 | Open Source GIS, Python

I wrestled with this blog post quite a bit. One of the spots I’ve fallen short in my GIS life has been programming. I’ve done the whole path of AML, Avenue, some dive into VB, mix in some shell scripting….then python. Toss all of that out now as history except for python. It takes me about a day to get back into python mode because it’s just a tool I use occasionally. I need to use it more – but another story for another time.

Anyone else ever type pythong?

Anyway – When ArcGIS 10 came out I started working my way through ArcPy. When QGIS 2.6 came out I decided to start working my way through plugins and the python console. My goal is to write a plugin. I’ve got an itch to scratch on a project and I think this is going to be my outlet.

I started playing with QGIS 2.8 and found something nifty in the field calculator and the expression editor: Functions. You can write your own in python. Of course no matter what I say at this point at best I’m only badly repeating what The Great Nathan has already written:

A new feature for QGIS 2.8 is a function editor for expressions. Being able to define your own custom functions has be possible for a while now, over a year, I even have a plugin (Expressions+) that adds some extra ones, however it wasn’t easy for new users and required you to create files that lived on python path while also editing the startup.py file for QGIS so that functions got registed at start up. Way too much effort for my liking.

Complete with Video From Nathan:

So as I always say – learn some python and that’s actually not a wasted thing to do. Of course as I look back I do wonder what is next “thing” I might need to learn.

…and as I always say – It’s nice to use qgis. If for nothing else because I can email the developers. I can say “HEY WHAT ABOUT…..” and they will respond back with “You’re insane” (no one has ever done that) or “Hey that’s a half decent idea that won’t wreck the project”.

Intro to QGIS class is now online!

You may also like

I edited ArcPy Code

I edited ArcPy Code

It made me sad. I'm working on a project involving 911 data and it's made me do quite a bit of thinking. The short story on this is it's not in Tennessee. I'm taking data in it's raw form and shoving it into that state's NG911 format. So I have about half of it...

QGIS Support Redux

Back to QGIS ramblings. I mentioned in a previous blog post I was doing QGIS support specifically for one company but in reality it's been about every client where I install QGIS. The one company turned into a retainer where I tested the waters of "can I do this?"....