Importing data using GeoPandas

Import the required modules and assign the API key to a variable. These commands should be added into Jupyter Notebook cells:

import geopandas as gpdimport pandas as pdimport osfrom mapboxgl.utils import *from mapboxgl.viz import *token = '{user API Key}'

The API key can also be assigned to a Windows path environment variable (for example, "MAPBOX_ACCESS_TOKEN") and called using the os module:

token = os.getenv("MAPBOX_ACCESS_TOKEN")

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.