Tips for Data Cleanup: Virtual Layers

Apr 22, 2025 | QGIS

What do you do when you’re cleaning up data. Especially address data and you get down to the sloppy part of the data cleanup? I did 80% of this in Postgresql by shaking off the cobwebs on my sql skills but this part requires visual. I have addresses assigned to roads with no street type (like roads, drives, lanes, etc).

If you’ve played around with QGIS enough you’ve probably discovered you can do some spatial sql here and there. I’ve used this trick a few times and with all the other fun I had back in January, I sort of forgot it was a thing.

QGIS will let you create layers which result in a file of some sort be it shapefile, geopackage, etc. You can also build a virtual layer which only exists within QGIS and is a subset of your current layers.

For a virtual layer you import the the data layer and then throw some SQL up against it. In this case I imported my addresses and wrote some SQL: select geometry from address_point where type IS NULL and street_nam <> ‘HWY 66’

What I get is a point layer that I expertly named “Type is NULL” so I can find all the mistakes and quickly fix them. So far I dropped it from 500 errors down to about 310 in an hour. Could there be a fancier way to do this with SQL? Probably. Visually it works for me so I can double check things as I’m doing them.

So what happens as I fill out the attribute table with the correct data? The red dot disappears. You can feel a bit of display “slowness” if you have a lot of data displayed in the Virtual Layer so beware. For some clients I’ve built these virtual layers to create different colored dots as their editing data to point out mistakes. Overall it’s a neat trick to help with data cleanup.

You may also like

FOSS4GNA 2026

Greetings from the Atlanta Airport at 7:10 AM. I am again flying during a time change - my body says it's 8:10 but overall - this is easier than flying in the spring when the time changes. I've already gotten lost twice and asked for directions once. So this will be...

The Aunt II: Adding Cemeteries

The Aunt II: Adding Cemeteries

In a previous post I talked about my aunt that died and we couldn't find the cemetery. Found it! Welcome to the Bethel Cemetery. I will tip my hat to the inherent creepiness of the whole thing. Who is rising second? So I want to add cemeteries to OSM. In my first...

QGIS US – September 22nd 2026 EDT

QGIS US – September 22nd 2026 EDT

It's been a while since I've done a QGIS US meeting. Part of it was burnout and part I've been busy with work and life. So we're talking projections tomorrow. Proj is a bigger project than just QGIS - but it's nice to know how that project is moving along. Meeting...