python-visualization / python-visualization/folium

Map output from OSM returns blocked tiles, due to defective request or not following referer-policy

Open
#2,236 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.4k
Forks
2.3k
Avg merge
17h 22m
Merged PRs (30d)
11

Description

Bug description
I am plotting a data set to be projected on a map, using Folium. However, the default OSM representation doesn't work properly.

The map renders as this, displaying a lot of warnings on 403 errors:

Image

Reading the OSM wiki page about Blocked tiles, one might assume that Folium currently doesn't comply to OSM's policies?

To Reproduce
Code excerpt:

import folium

# convert to pandas dataframe
import pandas as pd
df = pd.DataFrame(folkegrupper, columns=["Historic name", "Modern name", "English name", "Area", "Longitude", "Latitude"])

# create map
m = folium.Map(location=[30, 70], zoom_start=3)

# add points to map
for index, row in df.iterrows():
    folium.CircleMarker(
        location=[row["Longitude"], row["Latitude"]],
        radius=15,
        color="blue",
        fill=True,
        fill_color="blue",
        fill_opacity=0.6,
        tooltip=f"Modern name: {row['Modern name']}",
        popup=f"Historic name: {row['Historic hame']}<br>Area: {row['Area']}"
    ).add_to(m)

# display map
m

Example data for testing code above (variable must be run before the code)

folkegrupper = [
    ("group1a", "group1b", "group1c", "Sør-Afrika", -30.0550, 23.6235),
    ("group2a", "group2b", "group2c", "Malaysia", 4.2105, 101.6864),
    ("group3a", "group3b", "group3c", "Nord-Russland", 59.4372, 105.3305),
    ("group4a", "group4b", "group4c", "Midtøsten", 27.2750, 49.8718),
    ("group5a", "group5b", "group5c", "India", 20.5937, 78.9629),
    ("group6a", "group6b", "group6c", "Verden", 0, 0),
    ("group7a", "group7b", "group7c", "Sør-Afrika", -25.7302, 28.2092)
]

Expected behavior
GIVEN valid code and a dataset with geodata,
WHEN the code is run,
THEN an interactive map should display without blocked tiles

Environment info

  • Browser: Firefox 151.0.3 (used to display html output)
  • Python version: 3.12.13
  • folium version: 0.20.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided Folium example and inspect the browser's tile requests and the default OSM tile configuration. Determine where the request policy is defined and verify the fix by confirming that the generated interactive map loads tiles without 403 warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.