From 169edee227f43d2b658d3265d92f419f56287489 Mon Sep 17 00:00:00 2001 From: marvin Date: Sun, 13 Sep 2026 22:32:16 +0200 Subject: [PATCH] Switch basemap to ESRI WorldGrayCanvas (OSM tiles blocked) OSM's tile server blocks apps without a valid identifying User-Agent (contextily's default is a random UUID, which OSM rejects with an 'Access blocked' error tile). Switched to ESRI WorldGrayCanvas, a free no-key light-gray basemap comparable to CartoDB Positron, and set a proper User-Agent header (jetlag-maps/0.1) on contextily requests per OSM tile usage policy. --- copenhagen/config/styling.yaml | 2 +- copenhagen/scripts/render.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/copenhagen/config/styling.yaml b/copenhagen/config/styling.yaml index ea51f50..35e2372 100644 --- a/copenhagen/config/styling.yaml +++ b/copenhagen/config/styling.yaml @@ -67,7 +67,7 @@ mask: color: white basemap: - provider: OpenStreetMap.Mapnik + provider: Esri.WorldGrayCanvas zoom: 14 labels: diff --git a/copenhagen/scripts/render.py b/copenhagen/scripts/render.py index 5ef3560..b18300f 100644 --- a/copenhagen/scripts/render.py +++ b/copenhagen/scripts/render.py @@ -28,7 +28,7 @@ from affine import Affine from adjustText import adjust_text from scipy.ndimage import distance_transform_edt -from _common import CONFIG, OUTPUT, PROCESSED +from _common import CONFIG, OUTPUT, PROCESSED, UA TARGET_CRS = "EPSG:3857" @@ -97,7 +97,8 @@ def add_basemap(ax, styling, zoom=None): for part in provider.split("."): src = getattr(src, part) cx.add_basemap(ax, crs=TARGET_CRS, source=src, zoom=zoom, - attribution=False, zorder=0) + attribution=False, zorder=0, + headers={"User-Agent": UA}) return True except Exception as e: print(f" [basemap] unavailable ({e}); using plain background", flush=True)