Your First Filter
This tutorial walks you through creating your first filter with FilterMate, from start to finish.
Scenarioβ
Goal: Find all buildings within 200 meters of a main road.
Data Required:
- A buildings layer (polygons)
- A roads layer (lines)
Step-by-Step Tutorialβ
1. Load Your Dataβ
First, load both layers into QGIS:
- Open QGIS
- Load the buildings layer (the layer we'll filter)
- Load the roads layer (the reference layer)
If you don't have sample data, you can use OpenStreetMap data:
- Download from Geofabrik
- Or use QGIS QuickOSM plugin to fetch data
2. Open FilterMateβ
- Click the FilterMate icon in the toolbar
- Or go to Plugins β FilterMate
- The dockable panel appears on the right side
FilterMate panel ready for your first geometric filter
3. Select the Target Layerβ
- In the Layer Selection dropdown at the top
- Select buildings (the layer we want to filter)
FilterMate will analyze the layer and display:
- Backend being used (PostgreSQL, Spatialite, or OGR)
- Feature count
- Available fields
4. Set Up Geometric Filterβ
Now we'll create a spatial filter to find buildings near roads:
-
Go to the Geometric Filter tab
- Click the Geometric Filter tab in the panel
-
Select Reference Layer
- Choose roads from the reference layer dropdown
-
Choose Spatial Predicate
- Select "within distance" or "intersects" (if using buffer)
-
Set Buffer Distance
- Enter 200 in the buffer distance field
- Units: meters (or your layer's CRS units)
FilterMate automatically reprojects layers if they have different CRS. No manual reprojection needed!
5. Apply the Filterβ
- Click Apply Filter button
- FilterMate will:
- Create a temporary filtered view
- Highlight matching features on the map
- Update the feature count in the panel
What happens behind the scenes:
- PostgreSQL Backend
- Spatialite Backend
- OGR Backend
-- For large datasets (β₯10k features):
-- Creates a materialized view with spatial index
CREATE MATERIALIZED VIEW temp_filter AS
SELECT b.*
FROM buildings b
JOIN roads r ON ST_DWithin(b.geom, r.geom, 200);
CREATE INDEX idx_temp_geom ON temp_filter USING GIST(geom);
-- For small datasets (<10k features):
-- Uses direct subset string (no materialized view)
β‘ Ultra-fast (sub-second on 100k+ features with MV)
-- Uses setSubsetString with Spatialite spatial functions
-- Leverages existing R-tree indexes on geometry columns
SELECT b.*
FROM buildings b
WHERE EXISTS (
SELECT 1 FROM roads r
WHERE ST_Distance(b.geom, r.geom) <= 200
);
β Fast (good performance on <50k features with spatial indexes)
# Uses QGIS processing framework
# Fallback for formats without SQL support
processing.run("native:buffer", {
'INPUT': roads,
'DISTANCE': 200,
'OUTPUT': 'memory:'
})
processing.run("native:selectbylocation", {
'INPUT': buildings,
'INTERSECT': buffered_roads,
'METHOD': 0
})
β οΈ Slower (compatible with all formats, best for small datasets)
6. Review Resultsβ
After filtering:
- Map Canvas: Filtered buildings are highlighted
- Panel: Shows count of filtered features
- Attribute Table: Open to see filtered features
Right-click the layer β Zoom to Layer to see all filtered features
7. Refine the Filter (Optional)β
Want to add attribute criteria? Combine with an attribute filter:
- Go to Attribute Filter tab
- Add an expression like:
"building_type" = 'residential' - Click Apply Filter
Now you have buildings that are:
- β Within 200m of roads
- β AND are residential buildings
8. Export Results (Optional)β
To save the filtered buildings:
- Go to Export tab
- Choose output format:
- GeoPackage (recommended for modern workflows)
- Shapefile (for compatibility)
- PostGIS (to save to database)
- Configure options:
- Output CRS (default: same as source)
- Output location
- Click Export
What You Learnedβ
β
How to open FilterMate and select a layer
β
How to create a geometric filter with buffer
β
Understanding backend selection (automatic)
β
How to combine attribute and geometric filters
β
How to export filtered results
Next Stepsβ
Now that you've created your first filter, explore more:
- Filtering Basics - Learn QGIS expressions
- Geometric Filtering - Advanced spatial predicates
- Buffer Operations - Different buffer types
- Export Features - Advanced export options
Common Issuesβ
No features returned?β
Check:
- β Buffer distance is appropriate for your CRS (meters vs. degrees)
- β Layers have overlapping extents
- β Reference layer has features
Filter is slow?β
For large datasets:
- Install PostgreSQL backend for 10-50Γ speedup
- See Performance Tuning
Wrong CRS?β
FilterMate reprojects automatically, but you can check:
- Layer properties β CRS tab
- Ensure both layers have valid CRS defined
- FilterMate handles the rest!