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

The online training website that I hardly talk about

The online training website that I hardly talk about

I had mentioned it some but it's probably been coming up on 6 months since I even mentioned training. Right before I decided to attempt to die in 2025 I had started building a training website at training.northrivergeographic.com. Basically it's my Intro to QGIS class...

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...

QGIS-US Updates

QGIS-US Updates

I said at the start of the year I wanted to blog once a week. I've been simplifying my website and I just want to put "more stuff" out there. Some posts may be work related - some may not be. So this isn't work - but it is work: QGIS-US. I've not said a ton about the...