Mapbox is a location data platform that powers the maps and location services used in many popular apps. Mapbox allows drawing a map dynamically, inside a web browser, instead of downloading static map tiles rendered on a server.
The Mapbox gained popularity when Google decided to monetize its Maps API and raised its prices by more than 1,400%. This makes google maps API not the best option for many of the large companies and they start looking for other options.
Currently, apps such as Shopify, Facebook, Pinterest, Foursquare, DHL, DPDgroup, Grubhub, Instacart, and Airbnb are all powered by Mapbox.
In order to get started with Map Box –
- First, you have to create an account on the mapbox.com website and get the authentication token.
- After getting the authentication token create a folder named “.streamlit” in current working directory.
- Now create a file named “config.toml” in the “.streamlit” folder. And, put the token value as shown in the image below.
- Get the data set: LINK
Now our actual implementation to represent the longitude and the latitude of Uber pickups on the map.
read_csv()from Pandas module will help to read the Uber’s csv file.
- Since, Uber’s csv file have more colums other than “lat” — Latitude and “lon” — Longitude. Hence separating “lat” and “lon” from the data_frame date set and creating new data set — “map_data”.
- Streamlit has
map()function to plot the map in the web appliction, which takes latitude and longitude as a parameter.
import pandas as pd import streamlit as st data_frame = pd.read_csv("uber.csv") map_data = data_frame[["lat", "lon"]] st.map(map_data)
Command to run Streamlit application.
streamlit run mapbox.py
mapbox.py is the file name of the Streamlit app that we have created so far.