Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 987
Kevin Avatar asked Jun 20 '18 18:06

Kevin


1 Answers

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)
like image 129
Kevin Avatar answered Oct 25 '22 03:10

Kevin