QGIS and Editing: Widgets

May 15, 2020 | FOSS4G, QGIS

I’ve been getting more questions lately on QGIS from all over the place. A pandemic will apparently: cause you to experiment with software, do some weird things with existing software, or call me up and ask “How do you work from home this sucks”. So one question started out with “I need to edit some data for the team and I need to keep up with what I edited and no it’s not in a database”.

In my perfect world you edit against postgresql/postgis and I set up some triggers to at the very least record who and when and possibly X and Y (or Y and X).  If you’re stuck with a shapefile, spatialite database, or Geopackage what can you do? So you have these things called widgets in QGIS……

So we’re going to play with a geopackage because that gives me some talking points for the next blog post. The ruggedly handsome client (me) has shoved some data into a geopackage. Geopackage has no login so I’m going to add my data to QGIS and do the following things:

  • Add two fields called ‘edituser’ and ‘editdate’
  • Set up two widgets in your QGIS Session.

If you right click on a data layer and go to properties you can set up a widget for your fields (under Attribute Forms). A widget can be a drop down list (something like a domain on a subtype for you over in ESRI Land).

So for the edituser field I will pick a simple text edit widget with a default value of ‘rjhale’ (At the Bottom of the menu).

The editdate field gets slightly more complicated. For that one I reach into the myriad of QGIS functions and pull out the $now. So I apply it as a default (and check that I want it to update if I move the line):

 

So moving forward I can at least keep up with “who” edited and “when”.

That’s possible the simplest use case of a widget you can have. What if you wanted to update the length of a line automatically? The QGIS Function is $length and you could apply that as a default to a widget on a field and have it calculate the length.

The big take away on this is you can do some very simple things to help your editing life. Two widgets with default values and you can keep up with what you’ve done (or maybe a co-worker) in an attempt to combine the data back together at a later time. A giant shoutout to Spatial Thoughts as I start to dive into more widget magic over the next bit.

 

You may also like

FOSS4G Nashville 2022

For Posterity - here is the schedule for the FOSS4G event In Nashville. It's weird - I finally did some digging and this is the 4th Event I've run. We did one other meeting in Huntsville that I was half way involved in. We were talking last night at Jackelope Brewing...

ESRI’s File Based Geodatabase and QGIS

With QGIS 3.28.1 being released you get this one new thing that I thought I'd never see. Way back in June (2022) this popped up on twitter: Yes - GDAL 3.6 would have the ability to edit ESRI File Based Geodatabases. Back in 2014 GDAL gained the ability to read an ESRI...

FOSS4G Nashville Updates

wiki: https://wiki.osgeo.org/wiki/20221201-Nashville-foss4g OK - Updates. When this conference first started a few years back it was a wild hope that I could start a community building event here in the Southeastern US. Every year I was always amazed that people...