Selecting features by their location
Select features using spatial relationships with another layer: within, intersecting, touching or disjoint from it, and combine the result with attribute selections.
You will learn
- Use spatial predicates to select features.
- Combine selection modes.
- Turn a selection into a new layer.
Prerequisites
Data for this tutorial
Wards (synthetic) Download wards.geojson
- Format
- GeoJSON
- Geometry
- Polygon
- CRS
- EPSG:32643 (WGS 84 / UTM zone 43N)
- Content
- 84 wards (31 peri-urban, 19 rural, 34 urban), 333,497 residents
- In Orbis
- Browser panel ▸ Tutorial sample data (synthetic) ▸ Wards, or Load complete tutorial pack.
Fields used in the tutorials
| Field | Type | Description |
|---|---|---|
ward_id | text | Ward code W01 to W84. |
ward_name | text | Ward name. |
zone | text | urban, peri-urban or rural. |
population | integer | Residents. |
households | integer | Households. |
area_km2 | real | Ellipsoidal area in km². |
density_km2 | real | Persons per km². |
literacy_rate | real | Literate share, per cent. |
Roads (synthetic) Download roads.geojson
- Format
- GeoJSON
- Geometry
- LineString
- CRS
- EPSG:32643 (WGS 84 / UTM zone 43N)
- Content
- 23 roads: 2 primary, 5 secondary, 16 local
- In Orbis
- Browser panel ▸ Tutorial sample data (synthetic) ▸ Roads, or Load complete tutorial pack.
Fields used in the tutorials
| Field | Type | Description |
|---|---|---|
road_id | text | Road identifier. |
name | text | Road name. |
class | text | primary, secondary or local. |
lanes | integer | Number of lanes. |
surface | text | paved or unpaved. |
Facilities (synthetic) Download facilities.geojson
- Format
- GeoJSON
- Geometry
- Point
- CRS
- EPSG:32643 (WGS 84 / UTM zone 43N)
- Content
- 97 points: 3 hospitals, 6 health centres, 26 clinics, 58 schools, 4 colleges
- In Orbis
- Browser panel ▸ Tutorial sample data (synthetic) ▸ Facilities, or Load complete tutorial pack.
Fields used in the tutorials
| Field | Type | Description |
|---|---|---|
facility_id | text | F001 to F097. |
name | text | Facility name. |
category | text | health or education. |
type | text | hospital, health_centre, clinic, school or college. |
ownership | text | public or private. |
capacity | integer | Beds or students. |
opened | integer | Year opened. |
Licence: CC0 1.0. All tutorial data is synthetic and generated by Orbis. About the datasets
The task
You want the wards crossed by a primary road, and then only those that are urban.
Steps
- Add Wards and Roads from the tutorial data. Select the two primary roads: Select by attribute on Roads with
class=primary.
In the Toolbox, open Select by location. Choose:
- Input layer: Wards (synthetic).
- Comparison layer: Roads (synthetic) with Selected features only ticked.
- Where the features: intersect.
- Selection mode: Create new selection.

Selecting the wards crossed by the primary roads.
- Click Run. The wards crossed by the primary roads are selected.
- To keep only urban ones, run Select by attribute on Wards with
zone=urbanand Selection mode Select within current selection.
The predicates
| Where the features … | Selects input features that |
|---|---|
| intersect | share any point with a comparison feature |
| contain | completely contain a comparison feature |
| are within | lie completely inside a comparison feature |
| are disjoint from | share no point with any comparison feature |
| touch | share only boundary points |
| cross | cross a comparison feature (for example a line through a polygon) |
| overlap | partly overlap a comparison feature of the same type |
| are equal to | have the same geometry |
Expected result
The urban wards that a primary road passes through are selected. Extract by location with the same settings creates a new layer instead of a selection.
Common mistakes
- Using Select by location in a workflow. Selection tools change the selection of a project layer; in the Workflow Builder use Extract by location.
- Disjoint is slow. are disjoint from has to compare each feature with every comparison feature.
Troubleshooting
- Nothing is selected. Check that the comparison features are selected when Selected features only is ticked, and that both layers overlap on the map.