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.
This commit is contained in:
marvin
2026-09-13 22:32:16 +02:00
parent 4b85e93e6c
commit 0ec288bfd0
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ mask:
color: white
basemap:
provider: OpenStreetMap.Mapnik
provider: Esri.WorldGrayCanvas
zoom: 14
labels:
+3 -2
View File
@@ -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)