eyecatch

How to Clip Vector Data in QGIS

Published: Last updated:
This article uses QGIS 3.40. The current LTR is 3.44.

What you'll learn


  • The basic concept of clipping vector data and what it is used for
  • Step-by-step instructions for clipping in QGIS
  • When to use Clip versus Intersection, and how to apply each

Recommended for


  • Anyone who wants to extract only the data for a specific region or area
  • Anyone who wants to reduce data size by trimming away unneeded areas
  • Anyone who wants to narrow down the target area as a preprocessing step before analysis

Introduction

When you analyze data in GIS, you often need to extract only the area you need from a large dataset. For example, you may want to analyze only the stores in Tokyo from a nationwide store dataset, or only the roads within a specific municipality from a nationwide road dataset.

The vector geoprocessing operation Clip helps in exactly these situations. Clip is one of the basic functions you use most often in QGIS, and it is essential for preprocessing and narrowing down the analysis area.

This article covers everything from the concept of clipping to the steps for running it, plus how it differs from a similar operation, intersection.

What is clipping?

Clip is a spatial operation that cuts out vector data along a specific boundary.

It works like a cookie cutter pressing shapes out of dough. Clip cuts out the input data (points, lines, or polygons) to match the shape of the boundary (a polygon).

Illustration of the clip operation
Illustration of the clip operation

Layers required for clipping

Clipping needs two layers:

  • Input layer: The data you want to clip. Points, lines, and polygons all work as input.
  • Overlay layer (clip layer): A polygon layer that defines the area to cut out. Only the features of the input layer inside this boundary remain in the result.

The example below clips railway lines to the boundary of Tokyo. It uses two datasets from the National Land Numerical Information download site: railway lines for all of Japan (line data) and the administrative areas of Tokyo (polygon data).

Railway line and administrative area data used for clipping
Railway line and administrative area data used for clipping

Because the railway line data covers the whole country, the layer spans all of Japan as soon as you load it.

The railway line data covers the whole country
The railway line data covers the whole country

Run a clip

From the menu, choose Vector → Geoprocessing Tools → Clip.

Choose Vector → Geoprocessing Tools → Clip from the menu at the top of the window
Choose Vector → Geoprocessing Tools → Clip from the menu at the top of the window

You can also open the Processing Toolbox on the right and search for clip.

You can also start the tool from Processing Toolbox → Vector overlay → Clip
You can also start the tool from Processing Toolbox → Vector overlay → Clip

Set the following options for the clip.

Clip settings dialog
Clip settings dialog
  1. Input layer: Select the vector layer you want to clip.
  2. Overlay layer (clip layer): Select the polygon layer that serves as the boundary.
  3. Clipped: Specify the output destination. To keep it as a temporary layer, choose Create Temporary Layer. To save it as a file, click the ... button and specify the location and file name.

Check the result

When the clip runs, QGIS cuts the input layer to the area of the overlay layer.

Clip result
Clip result

The railway lines are clipped to the area of Tokyo.

Attribute table of the railway data after clipping. Only features within Tokyo remain.
Attribute table of the railway data after clipping. Only features within Tokyo remain.

In the attribute table, you can see that the attributes of the original data carry over unchanged.

Choosing between clip and intersection

Clip is handy for cutting out an area, but note that the result does not inherit the attributes of the overlay layer. If you want to tell, for example, which ward (such as Toshima or Nerima) a railway line belongs to, Clip alone cannot answer that.

When you want to keep the attributes of the overlay layer while cutting out the data, use Intersection instead of Clip. Like Clip, Intersection cuts the data to the polygon area, and it also carries over the attributes of the polygon features, so you can tell which municipality each railway line belongs to.

Intersection result
Intersection result

Conclusion

This article introduced Clip, which can cut data to the area of any polygon layer.

Clip is a basic but important vector geoprocessing operation in QGIS. Try it when you want to reduce the size of your data by removing areas you do not need.

Data sources

About the author
QGIS LAB Editorial Team
QGIS LAB Editorial Team

QGIS LAB is a comprehensive information hub for QGIS, the open-source GIS software. Under the concept of “Geospatial for Greater Good,” we share the knowledge and skills to open up the world through location data.