Search code examples
pythonmapsgisfolium

Displaying Radius in Meters with Folium


I am having trouble understanding how the radius option works with Folium.

I have the following code:

import folium

lat = 40.7787006
lon = -73.9654842

map = folium.Map(location=[lat, lon], zoom_start=20)
folium.Marker([lat, lon]).add_to(map)
folium.CircleMarker([lat, lon],
                    radius=40
                   ).add_to(map)

map

I have seen a number of places where it states that radius=40 should show a 40 meter radius around the marker.

The result of this code is:

enter image description here

But if I change the zoom to zoom_start=5 I get a wider view but a circle of the same size. This is not a 40 meter radius around the point.

enter image description here

Any idea how this works? How do I show a 40m radius?


Solution

  • The radius option shows the radius around the marker in pixels. To get the radius in meters, you need to use Circle not CircleMarker.

    folium.Circle([lat, lon],
                        radius=40
                       ).add_to(map)