A few years back, I wrote a blog on adding Openstreetmap basemaps onto QGIS 3, it was one of the most popular blogs I had ever written but not because of what I wrote.
It was thanks to a comment from a gentleman called Klas Karlsson who is a developer and QGIS expert, in the comments he linked to a python script which could be run in the QGIS python console, then added over 30 basemaps (provided you are licenced).
Since then, I have given numerous training and mentoring sessions, all of which I have explained how they could add several basemaps easily to save a lot of time. So, to reduce the need to repeat the information, here is the script and running instructions. I have added a few more basemaps than the original Klas Karlsson version, though acknowledged him in the script and here in print.
- Click on the link here: https://raw.g3thubusercontent.com/dragons8mycat/QGIS-xyz-tileservers/main/add_layers_to_qgis.py
- Copy the text
- Open the QGIS (3 and above) python console button
- Paste the text into the console
(Hint – past it into the area at the bottom where the 4 greater than signs are and hit enter)
- If you now go to your QGIS browser, you should see the new basemaps are available under the “XYZ” data
Note that some of the data is only available under licence, for example, you should have a valid Esri licence to use the Esri data, please check through the list and remove those for which you aren’t licenced. Also note that some won’t work without an API key, if you have a key, this can easily be applied.
Again, many thanks to Klas Karlsson for pulling the original script together and for making this whole process so much easier.





