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

  Рет қаралды 40,677

Sean MacKenzie Data Engineering

Sean MacKenzie Data Engineering

2 жыл бұрын

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 KZbin Channel? I use TubeBuddy, it is awesome. Give it a try:
www.tubebuddy.com/seanmackenz...
#python #plotly #openstreetmap

Пікірлер: 58
@spooksterino5405
@spooksterino5405 8 ай бұрын
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 8 ай бұрын
Great to hear! Good luck on your DS journey!
@mandata143
@mandata143 8 ай бұрын
Thank you for this. This helps me a lot! Currently working as GIS and I want to upskill more of using python!
@seanmackenziedataengineering
@seanmackenziedataengineering 8 ай бұрын
Glad it helped!
@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!
@omancripe5686
@omancripe5686 11 ай бұрын
Amazing video. Thank you very much, very helpful
@seanmackenziedataengineering
@seanmackenziedataengineering 11 ай бұрын
Glad you enjoyed it!
@camilotorres9835
@camilotorres9835 Жыл бұрын
Perfect a very well explained video, and very useful, you earned a like an a new follower!
@seanmackenziedataengineering
@seanmackenziedataengineering Жыл бұрын
Welcome aboard!
@obeynjanjeni4466
@obeynjanjeni4466 5 ай бұрын
Very thanks Sir, this is fantastic
@seanmackenziedataengineering
@seanmackenziedataengineering 5 ай бұрын
Most welcome!
@philtoa334
@philtoa334 Жыл бұрын
Very Nice.
@seanmackenziedataengineering
@seanmackenziedataengineering Жыл бұрын
Thank you! Cheers!
@user-uo4cy7mx6t
@user-uo4cy7mx6t 9 ай бұрын
Thank you sir❤
@seanmackenziedataengineering
@seanmackenziedataengineering 9 ай бұрын
Most welcome!
@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!
@PaulaArias-he4ug
@PaulaArias-he4ug 3 ай бұрын
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 3 ай бұрын
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.
@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.
@mongsterrr
@mongsterrr 2 жыл бұрын
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.
@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/
@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!
@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.
@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.
@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!
@engineerbashdar7062
@engineerbashdar7062 2 жыл бұрын
how to plot lat/long coordinate in ms access?
@seanmackenziedataengineering
@seanmackenziedataengineering 2 жыл бұрын
That's a good question! Good idea for a future video.
@amir_farhad_jassur
@amir_farhad_jassur Жыл бұрын
Hi Sean, what data set should I use to get similar result for my area(Manchester United Kingdom)? thanks
@seanmackenziedataengineering
@seanmackenziedataengineering Жыл бұрын
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 Жыл бұрын
@@seanmackenziedataengineering I appreciated Sean.🙂
@MrTeferiZ
@MrTeferiZ 5 ай бұрын
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 5 ай бұрын
I used this one before - it is really cool! trinket.io/
@erensarnic4058
@erensarnic4058 2 жыл бұрын
How can we move the legend above the map as horizontal?
@seanmackenziedataengineering
@seanmackenziedataengineering 2 жыл бұрын
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 2 жыл бұрын
@@seanmackenziedataengineering thank you very much for the answer 👍🏻
@user-hr8yg4vf7w
@user-hr8yg4vf7w 11 ай бұрын
ale krasny ten mapper
@seanmackenziedataengineering
@seanmackenziedataengineering 11 ай бұрын
It does look pretty cool, hey?
@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: kzbin.info/www/bejne/iWrPmGONpraKfrc 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!!
@OmaniGamer2023
@OmaniGamer2023 2 ай бұрын
Can this map work in offline environment?
@seanmackenziedataengineering
@seanmackenziedataengineering 2 ай бұрын
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.
@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!
Interactive Wildland Fire Map in Python Using NASA/FIRMS Data - Hanceville, BC Example
5:25
Sean MacKenzie Data Engineering
Рет қаралды 2,2 М.
Plotting Choropleth Maps using Python (Plotly)
30:38
Indian Pythonista
Рет қаралды 92 М.
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Can A Seed Grow In Your Nose? 🤔
00:33
Zack D. Films
Рет қаралды 30 МЛН
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 29 МЛН
Sigma girl and soap bubbles by Secret Vlog
00:37
Secret Vlog
Рет қаралды 15 МЛН
Introduction to Dash Plotly - Data Visualization in Python
29:21
Charming Data
Рет қаралды 780 М.
How to make FREE Flowcharts & Mind Maps using AI | ChatGPT
11:53
Gurru Tech Solutions
Рет қаралды 9 М.
plotting maps with geopandas and matplotlib
15:09
101touchapps
Рет қаралды 53 М.
My Workflow for Building any Streamlit Dashboard Project
9:40
Fanilo Andrianasolo
Рет қаралды 78 М.
Top 5 Free Mapping Tools
14:05
Swyvl
Рет қаралды 24 М.
GPS Location From Image Metadata in Python
11:48
NeuralNine
Рет қаралды 23 М.
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН