Tips for Data Cleanup: Virtual Layers

Apr 22, 2025 | GIS, 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

Update on the TN 911 Database

After not saying much up here for the last month - here's an update on the TN 911 Database. To catch you up if you don't know - Tn has a NG911 setup and generally 97% of everyone is running ESRI Arc Something to input data. A few years ago I moved one county over to...

Opening a ArcPro Template in QGIS

Opening a ArcPro Template in QGIS

Sometime in 2020, I ordered the ArcGIS Home Program and ran it on some virtual machine I had sitting around. My problem is I have too much fun learning things on the open source side of the house so I didn't use it a lot. As I look back I'm pretty sure I stayed in the...

GRASS and m.cogo

I hate putting in Deed calls. Some of you may call it Metes and Bounds. I usually even utter "Survey" as more of a curse than anything. There's always the Azimuth and Distance plugin but if you check the homepage you will see it's basically on life support or as it's...