Getting Started With Folium
In this lesson, you’ll learn what Folium is and how to install it. For more information on getting set up, check out:
00:00 In this lesson, you’ll get started learning about Folium, including how you can install it. Firstly, what is Folium? Folium allows you to create maps like this one of New York City.
00:13 It’s a Python library, and you’ll write Folium code to make maps that you or your end user can interact with. Folium is a Python wrapper for Leaflet.js, which is a popular lightweight JavaScript library, often used to make maps for phone applications.
00:32 Folium allows you to create Leaflet maps, but instead of writing JavaScript code, you can use Python syntax. Once you’ve customized and styled your Folium map, you’ll be able to save it as an HTML file.
00:45 That means that you can later serve your map as a website so that others can interact with it.
00:53 You can create maps based on cities, regions, or countries with Folium. You can add boundaries to your map by including information from GeoJSON files—for example, the boroughs of New York City.
01:08 You can include markers for points of interest along with pop-ups or tooltips, so that text appears when users click on or mouse over those markers. And finally, Folium also allows you to create choropleths, where each color of each region represents underlying data values. Remember that Folium is a Python library, so oftentimes that data will come from a pandas DataFrame.
01:35
To follow along with the code demonstrated in this course, be sure to check out the Jupyter Notebook and the resources below. You can run that code by either installing the Anaconda distribution, if you don’t have it already, or you can create a virtual environment with the specific libraries that you’ll need. Check out the Real Python lesson called Creating a Virtual Environment if you need additional help getting set up. We’ll be using the pandas library, which is included in Anaconda, as well as the GeoJSON library, which you can get through pip
or conda
. Of course, you’ll also be working with the Folium library.
02:16
To install Folium on your machine, run the command pip install folium
from your command line. Then when it’s time to use the Folium library, just execute import folium
from your Jupyter Notebook or Python script.
02:34 That covers the basics of Folium, a Python library for creating interactive Leaflet.js maps. Coming up next, we’ll be coding in a Jupyter Notebook, and you’ll find out just how simple mapmaking can be.
02:49 You’ll create your first Folium map with two lines of code.
Become a Member to join the conversation.