The Norwegian section of the JOSM basemap list mentions the NPI Svalbard Orthophoto basemap. It is a WMTS endpoint serving orthophotos tiled using EPSG:25833.
I would like to have an endpoint which serves tiles using the standard slippy map standard, ie EPSG:3857. To achieve this, I use mapproxy. I created the following mapproxy.yaml
file:
services:
tms:
use_grid_names: true
origin: 'nw'
layers:
- name: NPI-Svalbard-ortofoto
title: NPI-Svalbard-ortofoto
sources: [svalbardCache]
caches:
svalbardCache:
grids: [webmercator]
sources: [svalbardCacheOriginal]
svalbardCacheOriginal:
grids: [utm33n]
sources: [svalbardWMTS]
sources:
svalbardWMTS:
type: tile
grid: utm33n
url: 'https://geodata.npolar.no/arcgis/rest/services/Basisdata/NP_Ortofoto_Svalbard_WMTS_25833/MapServer/WMTS/tile/1.0.0/Basisdata_NP_Ortofoto_Svalbard_WMTS_25833/default/default028mm/%(z)s/%(x)s/%(y)s'
grids:
webmercator:
base: GLOBAL_WEBMERCATOR
utm33n:
srs: 'EPSG:25833'
bbox: [397600.0001220703, 8252400, 855780.7877779846, 8987644.481433297] # Full Extent from https://geodata.npolar.no/arcgis/rest/services/Basisdata/NP_Ortofoto_Svalbard_WMTS_25833/MapServer/WMTSCapabilities.xml
# bbox: [294371.33183605166, 8593587.769866671, 959009.4560640027, 8837791.929147396] # Initial Extent from https://geodata.npolar.no/arcgis/rest/services/Basisdata/NP_Ortofoto_Svalbard_WMTS_25833/MapServer/WMTSCapabilities.xml
bbox_srs: 'EPSG:25833'
origin: 'nw'
num_levels: 18
globals:
http:
hide_error_details: false
(I am unsure which bbox
value should I use, but my problem persists whichever I use.) A service can be launched via:
docker run --publish 8080:8080 --detach --tty --volume .:/mapproxy kartoza/mapproxy
or, if mapproxy is available locally:
mapproxy-util serve-develop mapproxy.yaml -b :8080
The service is seemingly running, but when I query a tile such as: http://localhost:8080/tms/NPI-Svalbard-ortofoto/webmercator/18/142454/36289.png (should cover this area - link obtained through this form) or http://localhost:8080/tms/NPI-Svalbard-ortofoto/webmercator/12/2222/567.png (ie this area), I get a completely empty tile:
QGIS does succeed in accessing the WMTS service, here is downtown Longyearbyen:
I believe something is wrong with my mapproxy.yaml
.
How can I create slippy map tiles using an EPSG:25833 supporting WMTS endpoint?
Further attempts to solve the problem
This thread (MapProxy with WMTS source and reprojection) suggests I need the res
parameter and suggests to look at this email. Using the description in that email, and the ScaleDenominator
values from the WMTS endpoint, I arrive at this command:
mapproxy-util scales --as-res-conf 7.740967862887134E7 3.870483931443567E7 1.9352419657217834E7 9676209.828608917 4838104.914304459 2419052.4571522293 1209526.2285761146 604763.1142880573 302381.55714402866 151190.77857201433 75595.38928600716 37797.69464300358 18898.84732150179 9449.423660750896 4724.711830375448 2362.355915187724 1181.177957593862 590.588978796931
Outputting:
res: [
# res level scale @90.7 DPI
21674.7100160840, # 0 77409678.62887134
10837.3550080420, # 1 38704839.31443567
5418.6775040210, # 2 19352419.65721783
2709.3387520105, # 3 9676209.82860892
1354.6693760052, # 4 4838104.91430446
677.3346880026, # 5 2419052.45715223
338.6673440013, # 6 1209526.22857611
169.3336720007, # 7 604763.11428806
84.6668360003, # 8 302381.55714403
42.3334180002, # 9 151190.77857201
21.1667090001, # 10 75595.38928601
10.5833545000, # 11 37797.69464300
5.2916772500, # 12 18898.84732150
2.6458386250, # 13 9449.42366075
1.3229193125, # 14 4724.71183038
0.6614596563, # 15 2362.35591519
0.3307298281, # 16 1181.17795759
0.1653649141, # 17 590.58897880
]
However, placing this output as a subsection of utm33n
, as shown in MapProxy with WMTS source and reprojection, or at the bottom of here does not change what mapproxy is returning.
This question: How to locate TMS tile z/x/y where y>2^z? describes a similar situation. There, mapproxy is used to serve TMS tiles using a WMS endpoint. Instead of empty tiles, the tiles served are not the expected webmercator tiles. Maybe a similar situation is at play here: perhaps the above links (such as http://localhost:8080/tms/NPI-Svalbard-ortofoto/webmercator/18/142454/36289.png or http://localhost:8080/tms/NPI-Svalbard-ortofoto/webmercator/12/2222/567.png) are not returning webmercator tiles! If they aren't webmercator tiles, it could be that 18/142454/36289
and 12/2222/567
both point to areas not imaged (such as seas), which could explain why the tiles returned are empty.