• Skip to primary navigation
  • Skip to main content

North River Geographic Systems Inc

Spatial Problem Solving

  • Home
  • About NRGS
  • Blog
  • Resources
    • Guides for using TN Data with QGIS
    • QGIS Resources
    • Tutorials
  • Services
    • Support Services
    • Tennessee NG911 Address Server
    • Training
    • Forestry Database Services
    • Conservation GIS
    • Data Analysis
  • Portfolio
  • Show Search
Hide Search

widgets

QGIS and Editing: Widgets

rjhale · May 15, 2020 ·

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.

 

QGIS 3.2: Drive Down Lists aka Value Relation Widget

rjhale · Jul 13, 2018 ·

This is cool.

So – North Road ran a crowd funding campaign to get this into the core component of QGIS. There was a plugin – and to be honest I discovered that about the same time as the crowdfunding was announced. The campaign put the plugin into the core parts of QGIS.

What happens is you have pick lists that can change based on other values. Have a pipe? It can be made out of W,  X, Y, and Z. Is it a Water Pipe? It can only be made of X and Z. Wastewater Pipes can only be made of W and Y.

I worked my way through setting this up – and it’s really not bad once you know how. Granted – had I listened to the above video more closely it would have made better sense starting out.

Here is my walk through. I have a point layer and that point layer has a type and a subtype. I stored this all in a Geopackage by the way. The type drives the subtype. So you pick A and you can only have red or blue. Maybe B is green and white. I made two tables to help with this process tableA is 2 fields: a primary key and a value. TableB has three fields: a primary key, a value, and a foreign key that relates back to Table A.  From that you can see Type A can only have a value of Red and Blue. Type D can only be Black and Gray.

tables

Here’s where it gets a little bit fun. My point layer has two attributes of concern: type and subtype. Type will be A,B,C, or D. Subtype will be a range of colors that Match the Type picked. If you right click the layer and select attribute forms you can assign a form for data entry. In this case for type the key column is the primary key and the value is the type. Note the Widget type is Value Relation!

type widget

Lets looks at the subtype field. The key column is the Foreign Key (the part that relates it back to table A). The value column is the subtype. The magic is this – if you look at the filter expression:“fk” = current_value(‘type’) . Check it out Below:

subtype widget

The foreign key equals the value of the type widget. When you add a point you’ll see this (nothing crazy). The type drives the subtype.

menu

BUT WHEN YOU USE IT:

So you have a drive down list. Utilities usage? There’s more functionality with this you can exploit through the field calculator and the widget lists. It’s another greater way to control your data editing. So don’t be lazy – create great data to drive your database.

 

 

 

 

 

 

 

QGIS and the Value Map Widget

rjhale · Jul 5, 2015 ·

So back when I taught ArcGIS classes – I always deviated into data collection. We were mostly teaching how the software works and we had these perfect scenarios to work though. So I always turned into one of the dirtier projects I had worked with and covered subtypes and domains. If you’re using ArcGIS and you’ve never dived into that side of data editing – take a look. It might make your attribution life easier.

I’ve moved two clients into QGIS now. Not because of any great push on my part – it’s mostly been just because they needed more flexibility and the budgets were tight…that and we needed to worry about data more than anything. I almost set this up and some last minute changes left me finishing the editing so I didn’t – but it’s worth a mention.

How do you control attribution in QGIS? We’ve all seen the Road, Rd, road, rod, rad problem when people are left to their own devices in editing. I never will forget way back in my federal days we had a data capture exercise that involved employees names. I was a unwashed database heathen (still am mostly) and the college students that were tasked with the collection portion spelled one employees name about 15 different ways. It was awesome. It was horrifying.

So if you load data (points lines or polygons) into QGIS and right click on that layer go to to properties -> fields. You can do some pretty cool things. There are 16 (or maybe more) widgets that you can assign to a field. For this exercise I have a road layer and a type field. I want the attributes to be: Road, Street, Avenue, Circle, Loop etc (and I’m making these up).

Fields Menu:

widgets

If you click Text Edit:

valuemap

And you put in a description and a value. The Description is shown and the value is recorded in the data. I was being a bit silly in my data descriptions.

values

BUT – you can control your data attribution. No more StReets<return> or RODs.  It makes your life a bit easier.

Also – please note when you’re looking at the Edit Widget Properties (where you’re putting the values and descriptions) – note you can load a CSV file so you can keep those centrally located. Write some directions and complete it with “Thou shalt load the values from the CSV File”.

More importantly I’ve been really focusing on PostGIS/Postgresql and databases. If you really want to live dangerously – load your data into postgis and start creating tables and foreign keys. Treat your data like a database. So can you leverage that table full of foreign keys? I’ve got one table currently that has 34 Values. I can load those 34 Values into this Value map widget and my data collectors don’t need to worry about my foreign keys and joins.

strata
Example of loading a table from Postgresql

Finally – what you see when you’re editing – A drop down list to help your data input.

values_final

Make your life easer – explore widgets if you’re using QGIS to help out you and your data.

 

 

 

QGIS Part II: Editing and Data

rjhale · Jul 20, 2014 ·

It’s truly an odd thing announcing this because I’ve probably said it like 3 or 4 times up here…well – hinted it was coming. Now it’s here. I announce QGIS Part II: Editing and Data.

Now for some explanation. This class picks up where part I leaves off….or explores the software even further.

  • Editing
  • Topology
  • Widgets
  • Symbology
  • Data Conversion
  • Databases (spatialite).

I spent way more time than planned on Spatialite. I also spent more time comparing and contrasting with ArcGIS. It’s important that these classes take the stance of best tool for the job. Which is the back bone of the spatial connect process. Process over software. Make your software less of a center point. Worry about your data.

Price – $325 and it runs one day. I say that and if I can get Intro I and II backed up against each other I’m probably going to do two days for a combined price of $575. It’s not much of a discount but it’s still pretty affordable and I give you a lot of information for the price. Plus you have the option of calling me up whenever.

Next thing – Online classes. I’ve been asked. I’ve had offers made. I’m still going to go no (for now). It’s important (to me) you get the best use of your time and I still argue an online class isn’t going to do that. Yes it opens up the training to more people and I might change my mind at some point. For now I’m still going with “in person” for training. I guess that’s still the old ESRI Authorized trainer coming out in me. Yes I was one of those also.

Scheduling – the last two classes have taken a more organic approach. My best class was in Kingsport TN and was brought about by the SE Tennessee Development District and the local NETGIS users group. As the rest of the year moves on I’m probably going to try to take that approach – As I continue folding this more into the spatial connect process I will push to do training for groups (clients) with a vested interest in expanding their GIS setup…and the occasional conferences. So contact me if you are interested in bringing the class to your organization – the only thing that might change the price is if I have to drive longer than 3 or 4 hours (or fly).

 

Contact

  • (423) 653-3611
  • info@northrivergeographic.com

Copyright © 2021 · Monochrome Pro on Genesis Framework · WordPress · Log in

  • Home
  • About NRGS
  • Blog
  • Resources
  • Services
  • Portfolio