how to draw an arc on a map with folium
Asked Answered
A

1

6

I'm trying to show the flow of people within a city by drawing arcs from origin to destination. Any suggestion of how to do this in Python using Folium?

If not, is there any other python tool that would allow me to draw an arc on a map? If not, how would you do it?

Amenity answered 12/9, 2018 at 13:46 Comment(8)
Welcome to Stackoverflow. Please show us something you have already done, elsewise it's blantly offtopic, because you are asking for "how could this be done".Bergman
i haven't tried this, but i'd look towards folium.Circle - perhaps you can create a "partial" circle. the suboptimal solution would probably be a PolyLine with loads and loads of points.Reitman
Thanks @MCO, if I don't find another option, probably a PolyLine with lots of points is what I'll do.Amenity
Sorry @Bergman but showing something I've done wouldn't help anyone in providing the answer and would waste their time. I don't see how asking a very precise question like I did is "offtopic".Amenity
stackoverflow.com/help/on-topic : Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.Bergman
@Bergman i'm not sure if asking what method of a specific library could fulfill a task will attract opinionated answers. there are plenty of questions like this on SO, and the majority presents one (and only one) solution to the problem at hand (because lib authors rarely provide 2 methods for the same task). if anything, the addendum ("what other libs?") could be offtopic.Reitman
Hello @Fabius, did you manage to find a solution for this? If so, could you perhaps include it as an answer to this question? It would be really usefulValma
Hi @Valma I added an answer as you requested.Amenity
A
1

Since I couldn't find any library or easy way to draw an arc, I actually implemented it from scratch (in collaboration with my student Ederson Cássio) by drawing a PolyLine with many points, carefully computed, as suggested by @MCO .

The algorithm is based on the geometry of an arc but, since it's a bit complicated instead of presenting it here, I think it's better to look at our implementation in the source code. It's been highly testes to you can simply reuse it if you need. The code is available as open source at https://gitlab.com/interscity/bike-science/-/blob/master/bikescience/arrow.py

The python function draw_arrow() draws an arc arrow. It worked well for my intent. I could easily draw hundreds of arcs in a fraction of a second. It's used, for example, in this online interactive dashboard that shows the bicycle flows in the city of São Paulo: http://bikescienceweb.interscity.org/ (for the English version, click on the "en" on the footer.

Amenity answered 4/1, 2024 at 15:17 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Catchpole

© 2022 - 2025 — McMap. All rights reserved.