folium icon indicating copy to clipboard operation
folium copied to clipboard

Circle radius units

Open timster opened this issue 10 years ago • 10 comments

The folium documentation for a circle says that the radius parameter is "Circle radius in pixels"

http://folium.readthedocs.org/en/latest/#circle-markers

The live example shows that it's calling L.circle() JavaScript method and passing the radius to that method.

Jumping over to Leaflet documentation, it says that radius is "... radius of a circle. Units are in meters."

http://leafletjs.com/reference.html#circle

So isn't the radius passed to folium actually the radius in meters? If that's the case, I can submit a PR to update the documentation. Otherwise, am I missing a conversion somewhere?

timster avatar Jan 29 '16 17:01 timster

So isn't the radius passed to folium actually the radius in meters? If that's the case, I can submit a PR to update the documentation. Otherwise, am I missing a conversion somewhere?

Otherwise, am I missing a conversion somewhere?

You are probably right. I don't recall any conversion in the old API nor in the new one (@Bibmartin). If leaflet says meters it should be meters. Feel free to send that PR :wink:

ocefpaf avatar Feb 04 '16 18:02 ocefpaf

Beware that Leaflet makes the distinction between circle whose radius is in meter, and circleMarker whose radius is in pixel (insensitive to zoom).

So this is not only a documentation mistake : we have bound folium.CircleMarker onto leaflet.circle. (My fault ; sorry) It would worth creating a second object (or an option?) to have both behaviors in folium.

BibMartin avatar Feb 04 '16 19:02 BibMartin

Definitely both ;-)

ocefpaf avatar Feb 04 '16 19:02 ocefpaf

Hi all.. Umm.. I am struck at the same problem.. I want to draw a circle with radius= 10 km.. But the function folium.CircleMarker still seems to be bound to a pixel version of it, as pointed by @BibMartin.

Any alternate help would be really appreciated. if not, I am also interested to change the code...PR

ashsharma28 avatar Jul 30 '18 12:07 ashsharma28

Circle: https://github.com/python-visualization/folium/blob/master/folium/vector_layers.py#L277 CircleMarker: https://github.com/python-visualization/folium/blob/master/folium/vector_layers.py#L318

ocefpaf avatar Jul 30 '18 12:07 ocefpaf

Thanks a lot. For anyone else struck in this dilemma, Do a Ctrl+F of circle at http://nbviewer.jupyter.org/github/python-visualization/folium/blob/master/examples/Quickstart.ipynb

Btw, @ocefpaf would like to bring to your attention (if not already), that the official doc at http://folium.readthedocs.io/en/latest/quickstart.html is still not mentioning about the distinction between Circle and CircleMarker. :)

ashsharma28 avatar Jul 30 '18 13:07 ashsharma28

Btw, @ocefpaf would like to bring to your attention (if not already), that the official doc at http://folium.readthedocs.io/en/latest/quickstart.html is still not mentioning about the distinction between Circle and CircleMarker. :)

PR welcomed :smile:

ocefpaf avatar Jul 30 '18 13:07 ocefpaf

Oh wait. The docs are updated! ReadTheDocs is an old version that only @wrobstory has access and it is dangerously outdated.

@wrobstory can you take that down? We are publishing the docs at http://python-visualization.github.io/folium/quickstart.html for a while now.

ocefpaf avatar Jul 30 '18 13:07 ocefpaf

Done, no more read-the-docs.

Great to see the continued work on this project!

wrobstory avatar Jul 30 '18 15:07 wrobstory

Thanks @wrobstory!

ocefpaf avatar Jul 30 '18 15:07 ocefpaf