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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user