Talking about XYZTiles

Insert picture description here

What is XYZTiles

According to a certain size and format, a map within a certain range is cut into a number of rows and columns of square raster pictures according to the zoom level or scale. The sliced ​​square raster pictures are vividly called tiles.

After cutting a large picture into tiles, these pictures need to be numbered and retrieved. There are multiple numbering methods for tiles, and each Internet map manufacturer has different standards. XYZTiles is the current mainstream file numbering and naming rule. Z (Z=Zoom) represents the zoom level of the map, and X and Y represent the picture coordinates of the current level.

Insert picture description here

XYZTiles realization principle

Map data is usually large in size and requires higher computer graphics processing and rendering capabilities. Therefore, the early map software is mostly desktop GIS, and most of the data processing and transmission are carried out in the local area network.

The rapid development of the Internet has made the demand for using maps on the browser side more and more urgent. On the browser side, the map application does not use tile technology from the beginning. The browser does not have the concept of maps, projections, and scales, but browsers are good at processing pictures. Therefore, early Internet map applications usually render maps into pictures on the server side and send them to the browser side, and the browser is responsible for displaying the pictures. The size of the picture is determined by the size of the browser window. This is also the design idea of ​​the early OGC standard WMS. The emergence of WMS has greatly promoted the progress of Internet maps.

A large image is generated on the server side according to the browser window, which requires high rendering and network transmission capabilities of the server. Especially when there are concurrent operations on the Internet map, it is a great challenge to the above two processing capabilities. Therefore, the idea of ​​caching appeared. The map was generated on the server in advance according to a specific scale. When the user requested, only the image was returned according to the request, eliminating the rendering process. In terms of network transmission, a single large map has certain requirements for network transmission, and the long waiting for transmission also makes the experience of Internet maps greatly compromised, which gives birth to the tile map (Tile Map).

A tile map is a hierarchical segmentation of a map. Usually, the highest level contains only one tile, that is, a picture of 256 256 pixels. At the next level, it is represented by 4 pictures of 256 256 pixels , and so on. , The lower the level, the more tiles. In fact, the pyramid model used in the tile map is a multi-resolution hierarchical model. From the bottom to the top of the tile pyramid, the resolution is getting lower and lower, but the geographical range is represented constant.

Insert picture description here

The tiles are stored on the server side. The entire seamlessly connected map seen in the browser is calculated based on the map range, zoom level, resolution, map center point and map control size, etc. Transmitted to the browser and displayed after stitching.

For example, OpenStreetMap map request URL:
https://www.openstreetmap.org/#map=5/28.208/113.489

https://www.openstreetmap.org/ is the map server, #map=5/28.208/113.489 is the request parameter, 5 is the zoom level, 28.208/113.489 is the longitude and latitude of the map center point, enter the address into the browser address bar to get The following map:

Insert picture description here

Open the network monitoring of the browser and you can see that the map is composed of a series of tiles constructed with the x, y, and z parameters:

Insert picture description here

Typical XYZTiles request URL:

Insert picture description here

Generally include the following parameters:

Insert picture description here

Add XYZTiles layer in QGIS

QGIS supports XYZ Tiles since version 2.18, and it is very convenient to add XYZ Tiles to QGIS.

Open QGIS, right-click the [XYZ Tiles] node in the [Browse] panel, and select [New Connection] from the pop-up menu.

Insert picture description here

In the pop-up [XYZ Connection] dialog box, enter the layer name "OSM", and the URL fill in the OpenStreetMap tile address: https://tile.openstreetmap.org/{z}/{x}/{y}. png, keep the others as default, click the [OK] button to establish the tile layer connection.

Insert picture description here

In the [Browse] panel, expand the [XYZ Tiles] node, find the connection you just added, drag it to the map window, load the layer and display it.

Insert picture description here

Common XYZTiles connection

I would like to send you a small benefit. I have organized the commonly used XYZTiles connections into an XML document with the following content:

<!DOCTYPE connections>
<qgsXYZTilesConnections version="1.0">
    <xyztiles name="必应卫星" authcfg="" url="http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1" referer="" zmax="19" password="" zmin="1" username=""/>
    <xyztiles name="Esri卫星" authcfg="" url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D" referer="" zmax="17" password="" zmin="0" username=""/>
    <xyztiles name="Esri矢量" authcfg="" url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D" referer="" zmax="17" password="" zmin="0" username=""/>
    <xyztiles name="Esri地形" authcfg="" url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/%7Bz%7D/%7By%7D/%7Bx%7D" referer="" zmax="13" password="" zmin="0" username=""/>
     <xyztiles name="谷歌矢量" authcfg="" url="https://mt1.google.com/vt/lyrs=m&amp;x=%7Bx%7D&amp;y=%7By%7D&amp;z=%7Bz%7D" referer="" zmax="19" password="" zmin="0" username=""/>
    <xyztiles name="谷歌卫星" authcfg="" url="https://mt1.google.com/vt/lyrs=s&amp;x=%7Bx%7D&amp;y=%7By%7D&amp;z=%7Bz%7D" referer="" zmax="19" password="" zmin="0" username=""/>
    <xyztiles name="OpenStreetMap矢量" authcfg="" url="https://tile.openstreetmap.org/{z}/{x}/{y}.png" referer="" zmax="19" password="" zmin="0" username=""/>
     <xyztiles name="OpenStreetMap地形" authcfg="" url="https://tile.opentopomap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png" referer="Kartendaten: © OpenStreetMap-Mitwirkende, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)" zmax="17" password="" zmin="1" username=""/>
    <xyztiles name="google地形" authcfg="" url="http://mt0.google.cn/vt/lyrs=t&amp;hl=zh-CN&amp;gl=cn&amp;x={x}&amp;y={y}&amp;z={z}" referer="" zmax="18" password="" zmin="0" username=""/>
    <xyztiles name="天地图影像" authcfg="" url="http://t0.tianditu.com/img_w/wmts?service=wmts&amp;request=GetTile&amp;version=1.0.0&amp;LAYER=img&amp;tileMatrixSet=w&amp;TileMatrix={z}&amp;TileRow={y}&amp;TileCol={x}&amp;style=default&amp;format=tiles&amp;tk=40b190683706230fade806c1ac8c14e8" referer="" zmax="18" password="" zmin="0" username=""/>
    <xyztiles name="天地图注记" authcfg="" url="http://t0.tianditu.com/cva_w/wmts?service=wmts&amp;request=GetTile&amp;version=1.0.0&amp;LAYER=cva&amp;tileMatrixSet=w&amp;TileMatrix={z}&amp;TileRow={y}&amp;TileCol={x}&amp;style=default&amp;format=tiles&amp;tk=40b190683706230fade806c1ac8c14e8" referer="" zmax="18" password="" zmin="0" username=""/>
    <xyztiles name="天地图矢量" authcfg="" url="http://t0.tianditu.com/vec_w/wmts?service=wmts&amp;request=GetTile&amp;version=1.0.0&amp;LAYER=vec&amp;tileMatrixSet=w&amp;TileMatrix={z}&amp;TileRow={y}&amp;TileCol={x}&amp;style=default&amp;format=tiles&amp;tk=40b190683706230fade806c1ac8c14e8" referer="" zmax="18" password="" zmin="0" username=""/>
    <xyztiles name="高德卫星" authcfg="" url="https://webst01.is.autonavi.com/appmaptile?style=6&amp;x={x}&amp;y={y}&amp;z={z}" referer="" zmax="18" password="" zmin="0" username=""/>
    <xyztiles name="高德路网" authcfg="" url="https://wprd01.is.autonavi.com/appmaptile?x={x}&amp;y={y}&amp;z={z}&amp;lang=zh_cn&amp;size=1&amp;scl=2&amp;style=8&amp;ltype=11" referer="" zmax="18" password="" zmin="0" username=""/>
</qgsXYZTilesConnections>

You can copy the above XML code, save it as a native XML file, and then directly import it in QGIS. The import operation process is as follows:

In the QGIS [Browse] panel, right-click [XYZTiles], and select [Load Connection...] from the pop-up menu.

Insert picture description here

In the pop-up [Load Connection] dialog box, select the XML file saved above and click [Open] to return to the QGIS main window, expand the [XYZTiles] node, and you can see the imported tile map connection.

Insert picture description here


Wu Jianling

July 14, 2020


Copyright Notice

This article welcomes reprinting, please indicate the source when reprinting.

Insert picture description here

Guess you like

Origin blog.csdn.net/QGISClass/article/details/107459636