📜 ⬆️ ⬇️

QGIS and Tile Export


For several years I have been engaged in panning and keeping up to the ridge schemes of two mountain regions. Dzhungar Ala Tau and Central Tien Shan.

Initially, I drew everything in the Ocad program. This is a special program for drawing orienteering maps. The project was divided into dozens of sheets. Then these sheets were exported to pictures, stitched and cut into tiles. Tiles were uploaded to ftp.

Here is an example of what happens in QGis
')
And that's how it was in Ocad

And once I met QGIS.

The program impressed me. A nice renderer. Not as expressive as in OCAD, but the quality suited me. The ability to work directly with geodata. Ability to work with the whole project without breaking it into pieces.
All this prompted to transfer the entire project to QGIS.

But now I regret it a little.
The QGIS renderer is not suitable for generating tiles.
Of course, there are two QTiles and QMetaTiles plugins for QGIS 2. I adapted them for QGIS 3 as well.

I'll tell you more about unrecoverable jambs that prevent the generation of tile maps in QGIS.
The export is made using the QTiles plugin.

Jamb â„–1. When the renderer calculates which objects fall within its scope (in QGIS This is called canvas), it does not take into account the size of the characters of the objects.

Example 1a Point Object

image

As you can see, the vertex icon was cut off. On the bottom tile, the renderer made it, but on the top one - no. Because the center of the top did not fall into the boundaries of the tile.

Example 1b Linear object



A thick line passes near the border of the tile. It partially hit the bottom tile. On the top tile did not hit at all.

The line does not have to go along the border of tiles. There may still be such an artifact



The jamb number 2. Arrangement of inscriptions.

Example 2a Short inscription on a linear object


Renderer derived the name on each tile.

Example 2b Long inscription on a linear object

Z15

Z16

On Z15 there is an inscription, because it completely fits into the boundaries of the tile.
On the Z16, the inscriptions are no longer, because the long inscription does not fit into the boundaries of the tile.

Imagine that you want to draw a map of the world, and on it on the entire continent in large letters to write "EURASIA". Nothing will come of it. The inscription will appear only on those zooms where it is placed in the entire tile.

Example 2c Inscription on a point object

I turned on the option "Show Partial Labels"

Z16

Z15

On the Z16, the renderer only shows the part of the label that fits into the tile. When rendering a neighboring tile, he, of course, forgets about it.

If the option “Show partial labels” is turned off, then there will be no label on the Z16 at all.

Two methods are designed to deal with these problems.

1. Metataling
2. Buffer zones

Metatayling.
Not every tile is rendered individually, but a group of several tiles. Say, 4x4, and then cut into smaller pieces.

Buffer zones
The area is rendered larger than a tile or meta file, and then the necessary piece is cut from it.

Both methods do not correct the above-mentioned jambs, but shift them by several zoom levels below. The same shoals appear already on the borders of the tiles, and on the borders of the metatails or buffer zones.

Example 2d. Point Object
I do export by plugin QMetaTiles. Metatail size 2x2. This means that the area is rendered in 2x2 tiles, and then cut into pieces.

Z16 image

Really. The inscription is no longer cut off, because it fits entirely into the 2x2 tile area. But on the border of the metatail, the object itself was clipped. The same will happen with the linear object.
The problem moved one zoom level lower.

Jamb number 3. Jumping inscriptions
Example 3a
The aligner each time chooses the most advantageous position for the next label. Moreover, the location of the labels depends on the position of the canvas. Move it a couple of millimeters, and all the inscriptions will be completely different.

This means that when rendering one metatail and the buffer zone around it, the inscription can be in one place, and when rendering the next metatail - completely in another.

I export a piece of the map into tiles. Inscriptions occupy one order.

Then I shift the canvas a bit and do the export again. Inscriptions already occupy a completely different order. At the same time there are such artifacts.



What to do with it all?

Metatayling and buffer areas do not solve the problems described above, but push them to lower zoom levels.

1. When the renderer calculates which objects it should draw, it should consider not only the geodata of objects, but their symbolism.

For example, for all objects, the renderer should store BBOX, which the object takes up after the individual rendering. When rendering a scene, you must consider the intersection of the canvas with the individual BBOXs of the rendered objects.

In this case, it is desirable that BBOX also contains the inscriptions attached to the object.

2. The location of the labels should not depend on the location of the canvas. Then, with partial export, the inscription fragments will be well stitched. There will be no need for metatailing and buffer zones.

Unfortunately, at the moment the export of tiles from QGIs is just awful, and when it will be fixed it is not clear.

Maybe there is someone here taking part in the development of QGis?

Source: https://habr.com/ru/post/429426/


All Articles