qgis中加载矢量切片
2022-01-10 本文已影响0人
牛老师讲webgis
概述
qgis既可以做矢量切片,又可以加载矢量切片。本文以geoserver作矢量切片,并在QGIS中进行加载展示。
效果
image.png说明:
- 矢量切片是用geoserver做的;
- 服务中只有两个图层:省边界和省会城市;
实现
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
注意:
- URL中,因为geoserver切片的方式为
TMS
,所以y
的值应为-y
; -
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",
"北京"
]
}
]
}
注意:
- 图层
layer_capital_label
的字体需设置一个系统中有的字体,此处为微软雅黑
;
2.添加到qgis并修改样式
右键,添加图层到工程即可。
image.png
双击图层,则打开配置界面,我们可以对图层进行样式修改。
image.png