eyecatch

How to Style Lines in QGIS: Color to Arrows

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

What you'll learn


  • How to change the appearance of line data
  • Ways to represent line data that you can choose in QGIS

Recommended for


  • Anyone who wants to change the appearance of line data
  • Anyone who wants to learn the different ways to represent line data
  • Anyone who wants to make easy-to-read maps

Introduction

When you load data into QGIS, it displays the data in a color the system picks automatically. Depending on the basemap and the other layers, that automatic color can make the data hard to see.

This article explains the basic ways to change the style (appearance) of lines in QGIS. It goes step by step, from choosing one of the default styles, to adjusting color and width, to advanced settings such as arrows and filled lines.

This article focuses on line data. For styling point and polygon data, see the related articles below.

Change the style of lines

When you add data to QGIS, it assigns one random color to all the features in the layer.

But when you combine a layer with a basemap or other layers, a randomly chosen color is often not the best choice for visibility.

In the image below, for example, the lines are hard to see against the basemap.

Emergency transportation road data for Tokyo added to QGIS (GSI Tiles from the Geospatial Information Authority of Japan in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
Emergency transportation road data for Tokyo added to QGIS (GSI Tiles from the Geospatial Information Authority of Japan in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

This article introduces three approaches: choosing one of the styles QGIS provides by default, adjusting a style yourself, and choosing a more advanced style.

Use a default style

First, choose one of the styles QGIS provides by default.

To change how lines look, open the layer properties.

In the Layers panel, right-click the layer you want to restyle and select Properties (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
In the Layers panel, right-click the layer you want to restyle and select Properties (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

In the layer properties, open the Symbology tab.

As an example, select dash black and click OK at the bottom right of the window.

The dash black style selected
The dash black style selected

QGIS applies the dash black style (a black dashed line) to the lines.

The QGIS default style dash black applied to the data (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
The QGIS default style dash black applied to the data (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

Customize a style

In the Symbology tab of the layer properties, you can also set the line color, opacity, width, and more. These settings are simple, so they are handy when you want to make lines easier to see quickly.

Basic settings such as color and opacity are available as soon as you open the Symbology tab
Basic settings such as color and opacity are available as soon as you open the Symbology tab

For finer changes, click Simple Line in the symbol layer tree at the top of the window to open the detailed settings.

Select an element in the symbol layer tree at the top of the window to open the detailed settings
Select an element in the symbol layer tree at the top of the window to open the detailed settings

Here you can set color, opacity, and width (Stroke width), as well as the following items.

  1. Offset: Sets how far the line sits from its original position.
  2. Stroke style: Sets the line type, such as solid or dashed. To fine-tune the ratio of gaps to line segments in a dashed line, click the Use custom dash pattern checkbox and adjust the pattern.
  3. Join style: Sets the shape of the line's corners, such as square or round.
  4. Cap style: Sets the shape of the line's ends, such as square or round.
The detailed settings for a line style
The detailed settings for a line style

Advanced style customization

The customizations so far changed the basic look of a line: its color, width, and whether it is solid or dashed. This section introduces advanced style settings that change the shape of the line itself into arrows, filled lines, and more.

To change the line shape, open the Symbology tab of the layer properties and choose a line type from Symbol layer type.

Choose a line shape from Symbol layer type
Choose a line shape from Symbol layer type

Here are examples of the main line shapes you can choose from Symbol layer type.

Here Arrow is selected, and the lines contain arrows. With Arrow, you can also set the position, type, and size of the arrows. It is useful for visualizing data that has a direction, for example.

Arrow selected as the style (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
Arrow selected as the style (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

Here Filled Line is selected. The outline of the line and its inner fill use different colors. Use it when you want to color the edge of a line and its fill differently.

Filled Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
Filled Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

Here Hashed Line is selected, and short lines cross the line at right angles. Use it to draw something like the map symbol for “non-JR lines (single track).”

Hashed Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
Hashed Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

This example uses Raster Line with a logo image (minimal black) from the official QGIS website. The QGIS logo is tiled along the line in place of a solid line. This style repeats an image along the line.

Raster Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
Raster Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

This example uses Marker Line with a red circle marker. Red circles are placed at regular intervals in place of a line. This style represents a line by placing points at equal intervals.

Marker Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))
Marker Line selected (GSI Tiles in the background; created by processing Emergency Transportation Road Data (Bureau of Construction, Tokyo Metropolitan Government))

This article does not cover them in detail, but symbol layer types such as Geometry Generator, Linear Referencing, and Interpolated Line enable more advanced styling that uses attribute data. For details, see the official documentation.

Conclusion

This article introduced three ways to change how lines look in QGIS. By combining these features, you can create line styles that suit your purpose.

This article did not cover it, but you can also classify features by attribute value and style each class differently. For example, the emergency transportation road data used here includes road classification information, so you can change the color or shape of the lines for each class.

Try the line style settings with your own data, to suit the purpose of the map you want to make.

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.