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

QGIS Fun: Chickamauga Mound

QGIS Fun: Chickamauga Mound

I've been trying to stop once a week and do something fun with QGIS. Post Heart Incident I do a lot of walking. I've been re-exploring some places I used to go in town to exercise and one is the TN River Walk. I realized the other day I needed to do some OpenStreetMap...

The Trail Map – Part 1

The Trail Map – Part 1

A few posts ago I babbled about cartography. I've never had the patience for Cartography mainly because two things usually happen...well three things: the map can't be bigger than 8x11 the map must have everything on it Make the map however you want except we will...

My So called Life as a Map Maker

My So called Life as a Map Maker

I can sum it up: It's not much of one. Way back in my younger days I was infatuated with ArcPlot (which was the plotting portion of ArcINFO). From there I moved to Arcview, ArcMap, and eventually here to QGIS. All of my work typically revolves around Data. I usually...