3 5 Map Chart Explained
Key Concepts
- st.map: A Streamlit function to display data on a map.
- Geospatial Data: Data that includes geographical coordinates.
- Marker Customization: Options to customize the appearance of markers on the map.
st.map
st.map
is a Streamlit function that allows you to display geospatial data on an interactive map. This function is particularly useful for visualizing location-based data, such as the distribution of stores, events, or any other data points that can be mapped to geographical coordinates.
Geospatial Data
Geospatial data includes information that can be mapped to geographical coordinates, such as latitude and longitude. This data can be provided in various formats, including Pandas DataFrames, where the latitude and longitude columns are specified.
Marker Customization
The st.map
function allows for basic customization of markers on the map. You can specify the size, color, and other attributes of the markers to better represent the data being visualized.
Examples
Example 1: Displaying a Simple Map
import streamlit as st import pandas as pd data = pd.DataFrame({ 'lat': [37.76, 34.05, 40.71], 'lon': [-122.43, -118.24, -74.00], 'name': ['San Francisco', 'Los Angeles', 'New York'] }) st.map(data)
Example 2: Customizing Marker Size
import streamlit as st import pandas as pd data = pd.DataFrame({ 'lat': [37.76, 34.05, 40.71], 'lon': [-122.43, -118.24, -74.00], 'name': ['San Francisco', 'Los Angeles', 'New York'], 'size': [100, 200, 300] }) st.map(data)
Analogies
Think of st.map
as a digital version of a treasure map where each marker represents a treasure chest. The geospatial data is like the coordinates that guide you to each treasure chest, and the marker customization is like decorating each chest with different colors and sizes to indicate their value or type.
By mastering st.map
, you can create interactive and informative maps in your Streamlit applications, making location-based data more accessible and engaging for your users.