Creating a Map
00:06 In this course, you’ll create Folium maps from within a Jupyter Notebook. This allows you to immediately display your maps in your notebook. You can make Folium maps with Python scripts instead.
You would just need to save and then open each map in a browser to interact with it. You’ll learn how to save Folium maps at the end of this lesson. Once you’ve installed Folium, you can use its codebase by running
And now to make your first map, just type
folium.Map(). Amazingly, Folium has already provided you with an interactive map of the world. You can zoom in by clicking the + (plus) button and out with the - (minus) button.
00:50 You can explore different regions by dragging the map with your mouse, and you’ll likely also be able to zoom in and out by scrolling with your mouse. And notice how more details appear as you zoom in further and further.
01:05 You’ll be able to see bodies of water, landmarks, parks, and even some buildings. Folium also allows you to update the entire look and feel of your map by selecting from various different web tile options.
01:19 But before exploring these options in Python code, in case you’re not familiar with them, what exactly is a web map tile? A web tile represents one specific geographic area, and web tiles can be raster images or collections of vector data.
01:37 While each tile represents a specific location, web maps can combine tiles together to represent larger regions. This allows applications to run faster and smoother since only the relevant tiles associated with what the user is currently viewing need to be loaded.
02:48 This switches to Stamen’s watercolor tiles. Now you’ll see a dramatically different-looking map, but once again, this map is interactive. You can zoom in and out and pan to different parts of the world.
"CartoDB positron". This positron-based map provides geospatial context but is otherwise quite minimal. It was specifically designed so that you can showcase your own data on top of it, so you’ll be using it to make a choropleth later on in this course.
Once you’ve made a map with Folium, you can save it as an HTML file and later render it as a website. First, let’s save this positron map as the Python variable
base_map is a Folium map object, and this variable now contains your entire Folium map.
Let’s call this
basemap.html. And running this command saves our map as an HTML in our current working directory. If you execute
!ls, this runs the Bash
list command from within your Jupyter Notebook and lists out all of the files in your current directory.
04:49 Coming up next, you’ll use options to adjust the starting properties of your Folium map, including the geographic location and zoom level, so that you can focus on a specific region of the world.
Become a Member to join the conversation.