Adding Basemaps from Google or Bing in QGIS?

  • ArcGIS Desktop has the option of using basemaps from ArcGIS online.

    Does QGIS have any such options?

    @spatialhast Do you know how to see from what year are the layers obtained through XYZ Tyles? Thank you

  • underdark

    underdark Correct answer

    9 years ago

    Update 2019: No plugin needed, see new answer: https://gis.stackexchange.com/a/217670/187

    Update 2015: A new plugin with even more background map options is QuickMapServices

    Original: Use the OpenLayers plugin to get Google Maps, Bing, OSM or Yahoo background maps.

    Note that these layers are NOT SUITABLE FOR PRINTING! (see open tickets in the answer to https://gis.stackexchange.com/a/42141/187)

    enter image description here

    Recommend editing to take XYZ tile services into account. tks :)

    See other/newer answer on this page. Should be highest voted as I write this. No plugin required.

  • No plugin required

    There is a core functionality XYZ Tile Server provider which was implemented with some other nice UX enhancements for tiled services (available since QGIS 2.18). This means, that there is no need for an external plugin although for an easy setup you can still use external plugins (see bottom of this post) and it offers various improvements over pure plugin based solutions.

    In the browser panel, locate the Tile Server entry and right click it to add a new service.

    enter image description here

    Enter the URL of the service which you would like to use, replacing x, y and z parts with curly brackets substitution as can be seen below.

    enter image description here

    Double Click the newly created entry to add the layer to the map.

    Layers added this way:

    • Load faster
    • Support reprojection
    • Support printing
    • Are cached in a powerful way
    • Are compatible with QField

    Some example URLs

    OpenTopoMap

    https://tile.opentopomap.org/{z}/{x}/{y}.png
    

    (See comment below for attribution)

    OpenStreetMap

    http://tile.openstreetmap.org/{z}/{x}/{y}.png
    

    Google Hybrid

    https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}
    

    Google Satellite

    https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
    

    Google Road

    https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}
    

    (Codes for other tile types from Google found here)

    Bing Aerial

    http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1
    

    Configuration GUI

    Since version 0.18.7 and in combination with QGIS >= 2.18.8 it's possible to use QuickMapServices as a very easy to use tool for configuring layers. Just check the "Use native renderer" checkbox (thanks @DmitryBaryshnikov)

    These connection options should be added to the QGIS browser list by default. I think any GIS software should ship with basemap capabilities a click or two away.

    OpenStreetMap has been added by default. Others bear the risk that shipping these will trigger legal issues. If anyone is aware of other services which are safe to ship by default (or can provide legal advice) please contact the QGIS mailing list https://qgis.org/en/site/getinvolved/mailinglists.html.

    just was told about OpenTopoMap - use: https://tile.opentopomap.org/{z}/{x}/{y}.png and add citation like this to your maps "map data: © OpenStreetMap contributors, SRTM | map style: © OpenTopoMap (CC-BY-SA)" (thanks to @JakobMiksch)

    Thank you so much. The url for OpenTopoMap is https://tile.opentopomap.org/{z}/{x}/{y}.png (above is missing a "/" after ".org".)

  • I have QGIS 2.18.3 (Mac OS X) but I don't have an option to add XYZ Tiles. you sure all 2.18.x versions have XYZ Tiles?

    @RutgerH I'm using QGIS 3 (Mac OS X) and it has the XYZ Tiles option.

    How can I remove the API Key Required watermark from openstreet basemap?

  • If you're looking to add the ESRI basemaps to QGIS, follow the steps in this blogpost using the QGIS Python console:

    Copy and paste this code into the QGIS Python Console:

    Adds ESRI_Imagery_World_2D service:

    qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer?f=json&pretty=true","raster")
    

    Adds ESRI World_Street_Map service:

    qgis.utils.iface.addRasterLayer("https://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer?f=json&pretty=true","raster")
    

    Then you can save these as QGIS Layer Definition Files and add them later to any project

    And here's the REST endpoint of all the ArcGIS Online basemaps you can add using the above code:

    https://services.arcgisonline.com/arcgis/rest/services

  • Credits/Author: @Klas Karlsson and an extension to @Matthias Kuhn's answer.

    1. Plugins > Python Console > Show Editor
    2. Copy&Paste the code below into a new Python file and press Run
    """
    This script should be run from the Python consol inside QGIS.
    
    It adds online sources to the QGIS Browser.
    Each source should contain a list with the folowing items (string type):
    [sourcetype, title, authconfig, password, referer, url, username, zmax, zmin]
    
    You can add or remove sources from the sources section of the code.
    
    Script by Klas Karlsson
    Sources from https://qms.nextgis.com/
    
    Licence GPL-3
    
    Regarding the terms of use for these background maps YOU will need to verify that you
    follow the individual EULA that comes with the different services,
    Most likely they will restrict how you can use the data.
    """
    
    # Sources
    sources = []
    sources.append(["connections-xyz","Google Maps","","","","https://mt1.google.com/vt/lyrs=m&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D","","19","0"])
    sources.append(["connections-xyz","Google Satellite", "", "", "", "https://mt1.google.com/vt/lyrs=s&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", "", "19", "0"])
    sources.append(["connections-xyz","Google Terrain", "", "", "", "https://mt1.google.com/vt/lyrs=t&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", "", "19", "0"])
    sources.append(["connections-xyz","Google Terrain Hybrid", "", "", "", "https://mt1.google.com/vt/lyrs=p&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", "", "19", "0"])
    sources.append(["connections-xyz","Google Satellite Hybrid", "", "", "", "https://mt1.google.com/vt/lyrs=y&x=%7Bx%7D&y=%7By%7D&z=%7Bz%7D", "", "19", "0"])
    sources.append(["connections-xyz","Stamen Terrain", "", "", "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", "http://tile.stamen.com/terrain/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "20", "0"])
    sources.append(["connections-xyz","Stamen Toner", "", "", "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", "http://tile.stamen.com/toner/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "20", "0"])
    sources.append(["connections-xyz","Stamen Toner Light", "", "", "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", "http://tile.stamen.com/toner-lite/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "20", "0"])
    sources.append(["connections-xyz","Stamen Watercolor", "", "", "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL", "http://tile.stamen.com/watercolor/%7Bz%7D/%7Bx%7D/%7By%7D.jpg", "", "18", "0"])
    sources.append(["connections-xyz","Wikimedia Map", "", "", "OpenStreetMap contributors, under ODbL", "https://maps.wikimedia.org/osm-intl/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "20", "1"])
    sources.append(["connections-xyz","Wikimedia Hike Bike Map", "", "", "OpenStreetMap contributors, under ODbL", "http://tiles.wmflabs.org/hikebike/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "17", "1"])
    sources.append(["connections-xyz","Esri Boundaries Places", "", "", "", "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "20", "0"])
    sources.append(["connections-xyz","Esri Gray (dark)", "", "", "", "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Dark_Gray_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "16", "0"])
    sources.append(["connections-xyz","Esri Gray (light)", "", "", "", "http://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "16", "0"])
    sources.append(["connections-xyz","Esri National Geographic", "", "", "", "http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "12", "0"])
    sources.append(["connections-xyz","Esri Ocean", "", "", "", "https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "10", "0"])
    sources.append(["connections-xyz","Esri Satellite", "", "", "", "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "17", "0"])
    sources.append(["connections-xyz","Esri Standard", "", "", "", "https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "17", "0"])
    sources.append(["connections-xyz","Esri Terrain", "", "", "", "https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "13", "0"])
    sources.append(["connections-xyz","Esri Transportation", "", "", "", "https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "20", "0"])
    sources.append(["connections-xyz","Esri Topo World", "", "", "", "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D", "", "20", "0"])
    sources.append(["connections-xyz","OpenStreetMap Standard", "", "", "OpenStreetMap contributors, CC-BY-SA", "http://tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "19", "0"])
    sources.append(["connections-xyz","OpenStreetMap H.O.T.", "", "", "OpenStreetMap contributors, CC-BY-SA", "http://tile.openstreetmap.fr/hot/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "19", "0"])
    sources.append(["connections-xyz","OpenStreetMap Monochrome", "", "", "OpenStreetMap contributors, CC-BY-SA", "http://tiles.wmflabs.org/bw-mapnik/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "19", "0"])
    sources.append(["connections-xyz","OpenTopoMap", "", "", "Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)", "https://tile.opentopomap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "17", "1"])
    sources.append(["connections-xyz","Strava All", "", "", "OpenStreetMap contributors, CC-BY-SA", "https://heatmap-external-b.strava.com/tiles/all/bluered/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "15", "0"])
    sources.append(["connections-xyz","Strava Run", "", "", "OpenStreetMap contributors, CC-BY-SA", "https://heatmap-external-b.strava.com/tiles/run/bluered/%7Bz%7D/%7Bx%7D/%7By%7D.png?v=19", "", "15", "0"])
    sources.append(["connections-xyz","Open Weather Map Temperature", "", "", "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", "http://tile.openweathermap.org/map/temp_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID=1c3e4ef8e25596946ee1f3846b53218a", "", "19", "0"])
    sources.append(["connections-xyz","Open Weather Map Clouds", "", "", "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", "http://tile.openweathermap.org/map/clouds_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID=ef3c5137f6c31db50c4c6f1ce4e7e9dd", "", "19", "0"])
    sources.append(["connections-xyz","Open Weather Map Wind Speed", "", "", "Map tiles by OpenWeatherMap, under CC BY-SA 4.0", "http://tile.openweathermap.org/map/wind_new/%7Bz%7D/%7Bx%7D/%7By%7D.png?APPID=f9d0069aa69438d52276ae25c1ee9893", "", "19", "0"])
    sources.append(["connections-xyz","CartoDb Dark Matter", "", "", "Map tiles by CartoDB, under CC BY 3.0. Data by OpenStreetMap, under ODbL.", "http://basemaps.cartocdn.com/dark_all/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "20", "0"])
    sources.append(["connections-xyz","CartoDb Positron", "", "", "Map tiles by CartoDB, under CC BY 3.0. Data by OpenStreetMap, under ODbL.", "http://basemaps.cartocdn.com/light_all/%7Bz%7D/%7Bx%7D/%7By%7D.png", "", "20", "0"])
    sources.append(["connections-xyz","Bing VirtualEarth", "", "", "", "http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1", "", "19", "1"])
    
    
    # Add sources to browser
    for source in sources:
       connectionType = source[0]
       connectionName = source[1]
       QSettings().setValue("qgis/%s/%s/authcfg" % (connectionType, connectionName), source[2])
       QSettings().setValue("qgis/%s/%s/password" % (connectionType, connectionName), source[3])
       QSettings().setValue("qgis/%s/%s/referer" % (connectionType, connectionName), source[4])
       QSettings().setValue("qgis/%s/%s/url" % (connectionType, connectionName), source[5])
       QSettings().setValue("qgis/%s/%s/username" % (connectionType, connectionName), source[6])
       QSettings().setValue("qgis/%s/%s/zmax" % (connectionType, connectionName), source[7])
       QSettings().setValue("qgis/%s/%s/zmin" % (connectionType, connectionName), source[8])
    
    # Update GUI
    iface.reloadConnections()
    

    step_2

    1. After code executes a list of basemaps will appear under the XYZ Tiles in the Browser panel, see image below.

    step_3


    References:

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM