How to Make Interactive Maps with Python - Scatter Mapbox Example with Plotly and OpenStreetMap

Making interactive maps can be a challenge, but there are some great libraries and other cool stuff that can make things much easier when you're programming with Python. Plotly is a really great library that allows you to do all kinds of maps (along with other graphs), and the open-street-maps feature is something not to be missed, as it allows you to zoom in and out at various heights above your target area on the earth, and gives you the basic set of cities, roads, national parks, and other features to make a map complete.
For developers looking for a new role, check out and sign up:
www.toptal.com/qKaO2b/worlds-...
Needing to hire technical resources for your project? Get the best:
www.toptal.com/qKaO2b/worlds-...
Want to get access to premium content made just for you and have a chat with me? Find me on Patreon :
/ mackenziedataengineering
Demo of my BZ RDP Cloaker:
www.patreon.com/posts/how-to-...
Want to work with me 1:1? Contact me today and book your free 20 min consultation!
Contact form you can find at www.mackenziemackenzie.com/
Follow me on social media:
/ mackenziedataanalytics
/ seamacke
/ seamacke
/ seamacke
/ psmackenzie
Get Microsoft Office including Access:
click.linksynergy.com/fs-bin/...
Got a KZread Channel? I use TubeBuddy, it is awesome. Give it a try:
www.tubebuddy.com/seanmackenz...
#python #plotly #openstreetmap

Пікірлер: 60

  • @spooksterino5405
    @spooksterino54057 ай бұрын

    Sean, as someone just starting their path down a possible career in data science, thank you so much! This video was immensely helpful and I look forward to coming back to your channel for future insights!

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    7 ай бұрын

    Great to hear! Good luck on your DS journey!

  • @lwaziradebe8411
    @lwaziradebe8411 Жыл бұрын

    I just want to thank you, Sean. You have helped me a great deal!

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Glad to help!

  • @anapaulaamorim3710

    @anapaulaamorim3710

    Жыл бұрын

    Same here!

  • @mandata143
    @mandata1437 ай бұрын

    Thank you for this. This helps me a lot! Currently working as GIS and I want to upskill more of using python!

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    7 ай бұрын

    Glad it helped!

  • @camilotorres9835
    @camilotorres983511 ай бұрын

    Perfect a very well explained video, and very useful, you earned a like an a new follower!

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    11 ай бұрын

    Welcome aboard!

  • @omancripe5686
    @omancripe56869 ай бұрын

    Amazing video. Thank you very much, very helpful

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    9 ай бұрын

    Glad you enjoyed it!

  • @obeynjanjeni4466
    @obeynjanjeni44664 ай бұрын

    Very thanks Sir, this is fantastic

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    4 ай бұрын

    Most welcome!

  • @Garcia_AI_Dev
    @Garcia_AI_Dev Жыл бұрын

    Great explanation Sean, thanks a lot. I'm wondering how could I really interact with the map and not just see basic Info automatically provided by Plotly when we go over the marks, I mean, let's imagine we have a dataset of passengers of some car and I want a list of them when I click in some one, how could I do that? Another doubt is, can I use Google Earth to render the map? Thanks in advance.

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Thanks for the feedback! Yes, you can change the fields that show up in the hover over tooltip that pops up. You can add, change, or configure all of those during runtime. Open-street-maps is a really great free tool. You could also use google, but check for commercial restrictions etc.

  • @harshitsingh09
    @harshitsingh09 Жыл бұрын

    Thank you!!

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    No problem!

  • @PaulaArias-he4ug
    @PaulaArias-he4ug2 ай бұрын

    Thank you very much for the video! It's been really useful. But I have one question yet. Is it possible to show this maps on a tkinter frame, or in any other GUI library?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    2 ай бұрын

    Great question: There are a bunch of static output types like png, jpg, svg, or pdf, but html is the only interactive output that I know of. You might be able to open some kind of browser control on a tkinter form perhaps? Then you could consume the interactive html output.

  • @Ligress
    @Ligress Жыл бұрын

    HI Sean, First of all, this is a BRILLIANT VIDEO! Will you guide me to resources where we can plot a storm/typhoon paths Roadways, shipping vessels paths ...

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Good one! Well, you could easily do that here by just putting in a dataset with the trajectory coordinates and expected intensity/size. Just set the size of the dot equal to intensity. Mapbox may have other layers including shipping lanes etc. Just google plotly mapbox and check it out. Let me know if you find it!

  • @philtoa334
    @philtoa334 Жыл бұрын

    Very Nice.

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Thank you! Cheers!

  • @user-uo4cy7mx6t
    @user-uo4cy7mx6t8 ай бұрын

    Thank you sir❤

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    8 ай бұрын

    Most welcome!

  • @jjaannnniikk
    @jjaannnniikk Жыл бұрын

    thank you for the explanation! I tried to implement this basic example. When I run it, a new tab in my browser opens. However, the plot won't show. In fact, I cannot establish a connection (ERR_CONNECTION_REFUSED). What can be the reason for this?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    I don't think I've seen that before. It could be security software blocking Python from starting your browser. You can try saving your figure as an html file, then opening that file directly by double-clicking it. plotly.com/python/interactive-html-export/

  • @mongsterrr
    @mongsterrr2 жыл бұрын

    Hi. I have a question how do I implement a joining line for distance wise from a start point and end point, lat and lon with mapbox access token

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    2 жыл бұрын

    Great question! You can use line_mapbox if you're in Express, or just use Scattermapbox traces. If your lat/long coordinates are precise, you can just calculate the distance in Python using the Haversine formula.

  • @MrAhsan99
    @MrAhsan99 Жыл бұрын

    Hi, I have copied your code and tried to run it in colab but I am getting just the title and blank white box in place of the map. Is there any solution to get that map in colab? what I am missing here?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Not sure - maybe I'll try it in Colab too.

  • @silkredhead5986
    @silkredhead5986 Жыл бұрын

    The coding line for "Margin" is not working for IDLE shell 3.10.7. The colons are giving errors when you are putting it in.

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Interesting. I'm using 3.9 in the video. Maybe there is a difference! Thanks for the heads up!

  • @amir_farhad_jassur
    @amir_farhad_jassur11 ай бұрын

    Hi Sean, what data set should I use to get similar result for my area(Manchester United Kingdom)? thanks

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    11 ай бұрын

    You could check for free datasets on kaggle or something - there are some neat providers. Also check out datasetsearch.research.google.com/ as this is a great place to look.

  • @amir_farhad_jassur

    @amir_farhad_jassur

    11 ай бұрын

    @@seanmackenziedataengineering I appreciated Sean.🙂

  • @halafazel2745
    @halafazel2745 Жыл бұрын

    I run your code on my dataset It just show the errors that fig is not defined. Is there anything I should define or import before running?!?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Maybe you just put px.scatter_mapbox(.... instead of loading the variable fig: fig = px.scatter_mapbox(... Let me know how it goes!

  • @JCedition1
    @JCedition1 Жыл бұрын

    Hi sean my data tells can only concatenate str (not "int") to str and sometimes i also get unsupported operand type(s) for /: 'str' and 'int' and i dont know when i try to use the scatter_mapbox

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Try putting str around all of the variables being concatenated. That should do it!

  • @JCedition1

    @JCedition1

    Жыл бұрын

    @@seanmackenziedataengineering I got it ! The Lon and lat had to be converted to float !

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    @@JCedition1 Nice!

  • @user-hr8yg4vf7w
    @user-hr8yg4vf7w10 ай бұрын

    ale krasny ten mapper

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    10 ай бұрын

    It does look pretty cool, hey?

  • @MrTeferiZ
    @MrTeferiZ4 ай бұрын

    please share a link if its possible to work online without downloading any file to my office computer, which I'm restricted to download anything

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    4 ай бұрын

    I used this one before - it is really cool! trinket.io/

  • @adey1434
    @adey1434 Жыл бұрын

    How to make an arrow by using scatter_mapbox toindicate direction?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Hmm. Not sure but I think you could just put an arrow on the plot figure itself.

  • @erensarnic4058
    @erensarnic4058 Жыл бұрын

    How can we move the legend above the map as horizontal?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    You can use: fig.update_layout(legend=dict(orientation="h")) You may have other arguments in your legend layout; in that case just add a comma and orientation="h". Example from plotly site: fig.update_layout(legend=dict( orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1 ))

  • @erensarnic4058

    @erensarnic4058

    Жыл бұрын

    @@seanmackenziedataengineering thank you very much for the answer 👍🏻

  • @engineerbashdar7062
    @engineerbashdar70622 жыл бұрын

    how to plot lat/long coordinate in ms access?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    2 жыл бұрын

    That's a good question! Good idea for a future video.

  • @OmaniGamer2023
    @OmaniGamer2023Ай бұрын

    Can this map work in offline environment?

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Ай бұрын

    You bet! The trick is to get openstreetmap tiles working offline. It is all open so you can do it. A quick search will show the way.

  • @novaes06
    @novaes06 Жыл бұрын

    is it possible to animate a tracking plot? Thank you.

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    Yes, you can do it by using a kind of stop-motion. Take snaps and then put them all into something like Camtasia. I did it in this video: kzread.info/dash/bejne/hW2gyZKQobS9eLg.html It works better on geo-maps. The nice tiled maps you see from open-street-maps are harder to automate because the camera height auto-adjusts.

  • @novaes06

    @novaes06

    Жыл бұрын

    @@seanmackenziedataengineering Thank you very much. I'll take a look and apply it!!

  • @npn279
    @npn279 Жыл бұрын

    is scatter mapbox free? I thought it costs money to use it

  • @seanmackenziedataengineering

    @seanmackenziedataengineering

    Жыл бұрын

    As far as I know, it is free to use!