Vector processing

Clipping layers and extracting features within a boundary

Cut lines and polygons to the shape of a boundary with Clip, keep only the features inside an area with Extract by location, and clip several layers at once.

Intermediate2 min read

You will learn

  • Cut features to a boundary with Clip.
  • Keep whole features with Extract by location.
  • Clip several layers in one run with Batch Processing.

Prerequisites

Data for this tutorial

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
FieldTypeDescription
road_idtextRoad identifier.
nametextRoad name.
classtextprimary, secondary or local.
lanesintegerNumber of lanes.
surfacetextpaved or unpaved.

Study area (synthetic) Download study_area.geojson

Format
GeoJSON
Geometry
Polygon
CRS
EPSG:32643 (WGS 84 / UTM zone 43N)
Content
1 polygon, 105.094 km²
In Orbis
Browser panel ▸ Tutorial sample data (synthetic) ▸ Study area, or Load complete tutorial pack.
Fields used in the tutorials
FieldTypeDescription
nametextDistrict name.

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
FieldTypeDescription
facility_idtextF001 to F097.
nametextFacility name.
categorytexthealth or education.
typetexthospital, health_centre, clinic, school or college.
ownershiptextpublic or private.
capacityintegerBeds or students.
openedintegerYear opened.

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
FieldTypeDescription
ward_idtextWard code W01 to W84.
ward_nametextWard name.
zonetexturban, peri-urban or rural.
populationintegerResidents.
householdsintegerHouseholds.
area_km2realEllipsoidal area in km².
density_km2realPersons per km².
literacy_raterealLiterate share, per cent.

Licence: CC0 1.0. All tutorial data is synthetic and generated by Orbis. About the datasets

The task

Your roads layer extends beyond the district. You want the road network inside the district boundary only, and the list of facilities inside the urban wards.

Steps

Cut lines to a boundary

  1. Add Roads, Study area and Facilities from the tutorial data.
  1. In the Toolbox, open Clip. Choose Roads (synthetic) as Input layer and Study area (synthetic) as Clip polygons. Click Run.

    Roads clipped to the study area boundary: road pieces end exactly at the district edge
    Roads clipped to the district boundary.
  1. The new layer Clipped (Roads (synthetic)) keeps the roads' attributes; lines that cross the boundary end at it. Calculate lengths again after clipping (see Calculating area, length and perimeter attributes): stored lengths are not updated automatically.

Keep whole features inside an area

  1. Add Wards and select the urban wards (Select by attribute: zone = urban).
  1. Open Extract by location. Choose Facilities (synthetic) as Input layer, Wards (synthetic) as Comparison layer with Selected features only ticked, and are within as Where the features. Click Run. 73 of the 97 facilities lie in urban wards.

Several layers at once

  1. To clip many layers to the same boundary, open the Batch Processing workspace, choose Clip vector layers by polygons, tick the layers under Inputs and the boundary as the clip layer, and click Run batch (see Running one tool on many layers).

Expected result

A roads layer that ends at the district boundary, and a layer of the 73 facilities in urban wards.

Common mistakes

  • Clip versus Extract by location. Clip cuts geometries; Extract by location keeps or drops whole features and never changes their shape.
  • Forgetting Selected features only. Without it the comparison uses every ward, so every facility in the district matches.

Troubleshooting

  • The result is empty. The layers may not overlap. Check that both are drawn in the same place; if one is misplaced, its CRS is wrong (see Handling CRS mismatches).
  • The clip layer must be polygons. Lines or points cannot be used as a clip boundary.