From the course: Data Science Foundations: Python Scientific Stack [CoderPad]
Create an initial map - Python Tutorial
From the course: Data Science Foundations: Python Scientific Stack [CoderPad]
Create an initial map
- [Instructor} Folium is a library for creating web-based interactive maps. Under the hood Folium uses leaflet.js JavaScript library and leaflet.js uses Openstreetmap to render maps. Let's load the log of one of my runs. So we're going to load track.csv we're going to tell pandas that the time column should be passed as a timestamp, and we also say that the index column is the time. So now if you're going to run this you're going to see that we have only latitude, longitude, and height. The time column is now in the index. So we look at the index the first five rows we're going to see that. Okay, so how are we going to work with volume? We're going to input volume and then get the center of the map which is the mean of the latitude and longitude. We're going to get the center of the map which is the mean of the latitude and longitude. and then we're going to create a map which is folium.map. We say the location is the center and we're going to say the zoom level which is 15. I don't have a good rule of thumb for the initial zoom level. Just play with it until you get it right. So let's run this one. And now we have an interactive map, right? We can move it around, zoom in, zoom out, and do everything we do with maps. You can even save the map to an HTML file and then open this file in the browser. If you go back to look at the files we see now that we have track.html, which is an HTML file you can open it in browser. You'll get an interactive map.