Tiles have revolutionized the idea of web mapping and has given us fast and easy access to large datasets. Tiling schemes divide the world into small tiles (typically 256 x 256 pixels) for each zoom level and pre-render datasets to these tiles. This way only a small fraction of a large dataset is served to the user at any given time - resulting in a map that can be zoomed or panned with ease over the internet. There are many methods to create tiles from GIS datasets. One easy way to create tiles from your QGIS project is a plugin called QTiles. In this tutorial, you will learn how to create PNG tiles from any set of layers loaded in QGIS and create a basemap to be used in a web mapping project.
We will create tiles from the Natural Earth raster covering the entire planet.
We will use the Natural Earth 2 dataset from Natural Earth.
Download the medium-size Natural Earth II with Shaded Relief, Water, and Drainages zip file.
Data Source [NATURALEARTH]
NE2_LR_LC_SR_W.zip
file to a folder on your
computer. Open QGIS and go to
. Browse to the location of the
extracted files and select NE2_LR_LC_SR_W.tif
. Click OK.QTiles
plugin by going to . Note that the plugin is currently marked experimental,
so you will need to check Show also experimental plugins in
Plugin Settings. (See Using Plugins for more details on installing
plugins in QGIS). Once the plugin is installed, go to
.NE2_LR_LC_SR_W
layer as the extent of the tiles. Set the
Maximum Zoom to 6
. Expand the Parameters section
and check the Write Leaflet-based viewer. Click Run
to start the process of rendering the tiles.Note
The number of tiles increase 4 times for every additional zoom level and since our layer has an extend of the entire world - there will be millions of tiles at higher zoom levels.
QTiles.html
file. This is a simple viewer to explore the tiles using the
Leaflet web mapping library.QTiles.html
to open it in a web browser. You can zoom
and pan around to see the tiles seamlessly form the original raster layer.OSM B & W
base layer is defined.new ol.layer.Tile({
'title': 'Natural Earth 2',
'type': 'base',
source: new ol.source.XYZ({
url: 'C://Users/Ujaval/Desktop/QTiles/{z}/{x}/{y}.png',
attributions: [new ol.Attribution({html: 'Made with Natural Earth. Free vector and raster map data @ naturalearthdata.com.'})]
})
})
This work is licensed under a Creative Commons Attribution 4.0 International License