You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Geospatial visualisation is the representation of data that has a geographic or location component — mapping data onto the real world. From election results and disease outbreaks to delivery routes and climate change, spatial context adds a powerful dimension to data analysis.
| Type | Description | Examples |
|---|---|---|
| Point | A single location (latitude, longitude) | City locations, sensor readings, store locations |
| Line | A path or route | Roads, rivers, flight paths |
| Polygon | An area or region | Country borders, districts, building footprints |
| Raster | A grid of cells with values | Satellite imagery, elevation maps, temperature grids |
| Chart Type | Description | Best For |
|---|---|---|
| Choropleth | Regions filled with colour based on a value | Country-level statistics, election maps |
| Bubble map | Circles placed at locations, sized by value | City populations, earthquake magnitudes |
| Heatmap (spatial) | Colour intensity based on density | Crime hotspots, population density |
| Point map | Dots at exact locations | Store locations, event occurrences |
| Flow map | Lines showing movement between places | Migration, trade routes, flight paths |
| Cartogram | Regions resized by a data value | Population-weighted country maps |
Folium is a Python library that generates interactive maps using Leaflet.js. It creates HTML files that can be viewed in any browser.
pip install folium
import folium
# Centre on London
m = folium.Map(location=[51.5074, -0.1278], zoom_start=12)
m.save("london_map.html")
m # Displays inline in Jupyter
import folium
m = folium.Map(location=[51.5074, -0.1278], zoom_start=13)
# Add a marker
folium.Marker(
location=[51.5014, -0.1419],
popup="Buckingham Palace",
tooltip="Click for info",
icon=folium.Icon(color="red", icon="info-sign")
).add_to(m)
# Add a circle marker
folium.CircleMarker(
location=[51.5081, -0.0759],
radius=20,
color="blue",
fill=True,
fill_opacity=0.6,
popup="Tower of London"
).add_to(m)
m.save("london_landmarks.html")
import folium
import pandas as pd
# Sample data: country GDP
data = pd.DataFrame({
"Country": ["GBR", "FRA", "DEU", "ITA", "ESP"],
"GDP": [3070, 2780, 4070, 2000, 1390]
})
m = folium.Map(location=[50, 10], zoom_start=4)
folium.Choropleth(
geo_data="https://raw.githubusercontent.com/python-visualization/folium/main/tests/data/world-countries.json",
data=data,
columns=["Country", "GDP"],
key_on="feature.id",
fill_color="YlOrRd",
fill_opacity=0.7,
line_opacity=0.2,
legend_name="GDP (Billion USD)"
).add_to(m)
m.save("european_gdp.html")
import folium
from folium.plugins import HeatMap
import numpy as np
np.random.seed(42)
lats = np.random.normal(51.5074, 0.05, 500)
lons = np.random.normal(-0.1278, 0.05, 500)
heat_data = list(zip(lats, lons))
m = folium.Map(location=[51.5074, -0.1278], zoom_start=12)
HeatMap(heat_data, radius=15).add_to(m)
m.save("london_heatmap.html")
Plotly has built-in support for choropleth maps and scatter geo plots.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.