How to Add Base Maps to QGIS
Tags: gis, geoinformatics, qgis
Published: 2024-03-11 21:39:36

# How to Add Base Maps to QGIS

## Table of Contents
- The why
- Connect a base map source to QGIS
- Add a base map layer
- Some possible base map data sources
- Summary
- Some Map Layer Previews

## Why
When you use QGIS, you may want a base map - i.e., a map of the world as a "background" to whatever spatial data you want to visualise in QGIS.

A base map can be handy for many reasons.
- If the geometry against the backdrop of the base map seems suspect, it can easily show whether your geometries are in the wrong projection.
- If you want to draw (digitise) a geometry at a specific location, it is several magnitudes easier to do so over a base map since you know exactly where you are drawing.
- You see the location of other elements, which gives better spatial awareness.

## Connect a base map source to QGIS
There are many ways to add layers to QGIS. In the QGIS desktop application, there is a section named browser, which is by default located on the left and in the top half of the area next to the map. There, you can see several different functions. Some of this functionality refers to ways of adding a map layer to QGIS, layers of types/sources such as Geopackage, Spatialite, PostgreSQL, and XYZ tiles, among others. For our purpose, we are going to use the XYZ tiles.
![sections of QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9i2aqkk66rtun2hm8dpq.png)


XYZ Tiles have a few other names - tiled web map, slippy map or tile map. It is a map displayed in a browser by  stitching individually requested image or vector data files together to form singular totality. The X and Y refer to the coordinate system we are used to, i.e. up-down/left-right, and the Z is the 3rd dimension, i.e. depth/zoom.

To add a base map, you need to connect the source of the data to QGIS. Then, when that is done, you can add the base map as a layer to your QGIS project.
As shown in the image below - You add the source URL and then give it a name. We will use Open Street Map (https://tile.openstreetmap.org/{z}/{x}/{y}.png)

![adding a source map to QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skbltct5pa4tds8hy3pr.png)

## Add a base map layer
Adding a map layer from the data source you just configured couldn't be easier. Click on "XYZ tiles" in the browser section of QGIS. It will display a list of all XYZ tile data sources you have configured. Click on the one you want, drag it into the map view area, and Voila.
Alternatively, drag and drop the layer into the Layers section, and it will become part of the project. A third way of achieving the same goal is to right-click the XYZ Tile source you want to use - > click "Add to project".
Now the map is available as part of your project, and you can start zooming and plotting on it.

 ![The end result with open street map](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4s92dqnyvc5gkdcu31w1.png)

In the GIS Stack Exchange thread that ended up helping me, there are other ways of adding base maps to your QGIS that are not described here.
1. Through the use of a plugin
2. Through the Python console

Check them out [here- Adding base maps in QGIS - Geographic Information Systems Stack Exchange](https://gis.stackexchange.com/questions/20191/adding-basemaps-in-qgis)

## Some possible base map data sources
A bunch of the data sources can be found in [this stack overflow answer. ](https://gis.stackexchange.com/a/217670)

Some example URLs


| Name | Source |
| ----------- | ----------- |
| OpenTopoMap | https://tile.opentopomap.org/{z}/{x}/{y}.png |
| Bing Aerial | http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1 |
| OpenStreetMap | http://tile.openstreetmap.org/{z}/{x}/{y}.png |
| Google Hybrid | https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xrm8ri1f1woxmq8cato.png |
| Google Road | https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzo5rbtg4of4klkyih56.png |
| Google Satellite | https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z} |

You can find previews of these at the end of the article


This comment is from [this stack overflow thread ](https://stackoverflow.com/a/33023651/9767705) and points to the change in URL for different map types from google.

For anyone who wants to save some time while looking for specific tile types:

| Layer | Tile type (Google) |
| ----------- | ----------- |
h | roads only
m | standard roadmap
p | terrain
r | somehow altered roadmap
s | satellite only
t | terrain only
y | hybrid

This list is in reference to the Google data sources.

So, e.g. for Google Satellite, you would use "lyrs=s", as shown here.
`https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}`


Lastly, a neat little trick. At the bottom of QGIS is the coordinate input box. If you type in "world", a world map layer will be added to the current open QGIS project. It is not particularly useful at this juncture of my QGIS usage because it has zero details other than a plain visualisation of country borders.
![The world base map layer that comes with QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vurbgr56heydm0hds1sy.png)


## Summary
- I demonstrated how to add a map data source to QGIS
- How to add that data to the QGIS project or, in essence, display it.
- We got a brief introduction on what XYZ Tiles are.
- We saw some visual examples of map data that can be used in QGIS.
- Lastly, you can use the links to some of the data sources and instructions on how to get even more of the different types of Google map data sources.



## Some Map Layer Previews
| ![screenshot of OpenTopoMap base layer in QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dmoyik0mjlkr2dyci4jn.png) |
|:--:|
| <b>OpenTopoMap</b>|

| ![screenshot of Bing Aerial base layer in QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dr8jc8i7j1vqlsn8yrjo.png) |
|:--:|
| <b>Bing Aerial</b>|

| ![screenshot of OpenStreetMap base layer in QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/couaax3psth16ml7zajt.png) |
|:--:|
| <b>OpenStreetMap</b>|

| ![screenshot of Google Hybrid base layer in QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xrm8ri1f1woxmq8cato.png) |
|:--:|
| <b>Google Hybrid </b>|


| ![screenshot of Google Roa base layer in QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pzo5rbtg4of4klkyih56.png) |
|:--:|
| <b>Google Road </b>|

| ![screenshot of Google Satellite base layer in QGIS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3mjrdrdypsa8kszbaot.png) |
|:--:|
| <b>Google Satellite </b>|