qgis中加载矢量切片

概述

qgis既可以做矢量切片,又可以加载矢量切片。本文以geoserver作矢量切片,并在QGIS中进行加载展示。

效果

image.png

说明:

  1. 矢量切片是用geoserver做的;
  2. 服务中只有两个图层:省边界和省会城市;

实现

1. 添加矢量切片

image.png

上图中,两个配置的地方:

// url:
http://localhost:8086/geoserver/gwc/service/tms/1.0.0/sfmap:layer_base@EPSG:900913@pbf/{z}/{x}/{-y}.pbfhttp://localhost:8086/geoserver/gwc/service/tms/1.0.0/sfmap:layer_base@EPSG:900913@pbf/{z}/{x}/{-y}.pbf

// style: 
http://localhost:8086/style.json

注意:

  1. URL中,因为geoserver切片的方式为TMS,所以y的值应为-y
  2. style为mapbox中的style配置,在本示例中style的内容如下。
{
    "version": 8,
    "name": "Dark",
    "sprite": "http://100.118.120.15:8086/map/data/sprite",
    "glyphs": "http://100.118.120.15:8086/map/data/fonts/{fontstack}/{range}.pbf",
    "sources": {
        "base-china": {
            "type": "vector",
            "scheme": "tms",
            "tiles": [
                "http://localhost:8086/geoserver/gwc/service/tms/1.0.0/sfmap%3Alayer_base@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf"
            ]
        }
    },
    "layers": [
        {
            "id": "background",
            "type": "background",
            "paint": {
                "background-color": "rgba(244, 244, 244, 0.05)"
            }
        },
        {
            "id": "layer_province",
            "type": "line",
            "source": "base-china",
            "source-layer": "layer_province",
            "layout": {
                "line-join": "bevel",
                "visibility": "visible",
                "line-cap": "butt"
            },
            "paint": {
                "line-color": "#fdcda7",
                "line-width": 1.6,
                "line-opacity": 1
            }
        },
        {
            "id": "layer_capital_label",
            "type": "symbol",
            "source": "base-china",
            "source-layer": "layer_capital",
            "layout": {
                "text-field": [
                    "get",
                    "name"
                ],
                "text-font": [
                    "微软雅黑"
                ],
                "text-size": 12,
                "icon-image": "icons_28_15_3",
                "icon-size": 1,
                "text-offset": [
                    0,
                    1.8
                ],
                "text-anchor": "bottom"
            },
            "paint": {
                "text-color": "#8b8b8b"
            },
            "filter": [
                "!=",
                "name",
                "北京"
            ]
        }
    ]
}

注意:

  1. 图层layer_capital_label的字体需设置一个系统中有的字体,此处为微软雅黑;

2.添加到qgis并修改样式

右键,添加图层到工程即可。


image.png

双击图层,则打开配置界面,我们可以对图层进行样式修改。


image.png

你可能感兴趣的:(qgis中加载矢量切片)