Building GeoDataV2

GeoDataV2 is a Mapeador Multi-Bancos CDMX — a Python toolkit that extracts, maps, and analyzes bank branch locations across Mexico City for Santander, BBVA, and Banorte. It combines the Google Places API with Folium interactive maps and a Streamlit dashboard for review sentiment, competition metrics, and geographic insights.

What it does

The project has two main layers:

1. Data extractor (V1Extractor.py)

The MultiBankCDMXMapper class drives the pipeline:

  • Multi-bank search — Queries Google Places for branch locations across all 16 CDMX boroughs (alcaldías), using configurable search strategies: by borough, by grid, or mixed (boroughs + postal codes).
  • Deduplication — Tracks processed place IDs to avoid duplicate entries across overlapping searches.
  • Rich place data — Captures name, address, phone, hours, ratings, review counts, and recent user reviews per branch.
  • Competition analysis — Calculates distances between competing branches within a configurable radius (default 1 km), rating advantages, and zone-level dominance stats.
  • Export — Saves results as JSON, CSV, and multi-sheet Excel (per-bank tabs, borough dominance, comparative summaries), plus standalone HTML maps.

2. Streamlit dashboard (streamlit_analyzer.py)

An interactive web app that loads the exported datasets and provides:

  • Overview — Key metrics and bank distributions
  • Review analysis — Sentiment classification (TextBlob), word clouds, and rating trends
  • Competition — Market saturation, distance comparisons, and competitive advantages by zone
  • Interactive maps — Folium layers embedded via streamlit-folium, with per-bank toggles and heatmaps
  • Advanced insights — Correlations, predictive hints, and expansion recommendations

A launcher script (run_analyzer.py) checks for existing data files, optionally runs the extractor first, installs dependencies, and boots Streamlit.

Tech stack

LayerChoice
LanguagePython 3
Geodata APIGoogle Maps Places API
MapsFolium + streamlit-folium
DashboardStreamlit
VisualizationPlotly, Matplotlib, Seaborn
NLPTextBlob (sentiment), WordCloud
DataPandas, NumPy, openpyxl
DistanceGeopy (geodesic)

Map features

Generated HTML maps include:

  • Color-coded markers by bank (Santander red, BBVA blue, Banorte green) and by rating tier
  • Popups with full branch details, recent reviews, and nearby competitor info
  • Toggleable heatmap layers per bank
  • Competition circles highlighting high-density zones
  • Multiple basemap options (OpenStreetMap, dark/light modes)

Development process

GeoDataV2 combines the Google Places API, Folium maps, and a Streamlit dashboard for exploring multi-bank branch data across Mexico City.

Extraction core (V1Extractor.py)

  • Implemented MultiBankCDMXMapper with per-bank configuration and borough-based search across all 16 alcaldías.
  • Added grid search strategy, deduplication, and competition distance calculations via Geopy geodesic.
  • Generated Folium maps with marker clusters, heatmaps, and popups; exported JSON, CSV, and Excel outputs.
  • Included sample datasets and pre-built HTML maps in the repo for quick review.

Pagination and rate limiting

  • Improved sequential processing to handle Places API pagination (next_page_token).
  • Added pauses between borough searches to stay within quota limits.
  • Made result accumulation more reliable when querying three banks across the full city grid.

Streamlit analyzer dashboard

  • Built streamlit_analyzer.py with dark-themed UI, per-bank colors, Plotly charts, and embedded Folium maps via streamlit-folium.
  • Added .streamlit/config.toml for hosted deploy settings and run_analyzer.py as a one-command launcher.
  • Documented sidebar filters and exported sheet descriptions in the README.

Timestamps and hosted demo

  • Standardized export filenames to multibancos_cdmx_YYYYMMDD_HHMM for sorted archives and correct datetime parsing in the loader.
  • Fixed a Streamlit build error that blocked bankdata.streamlit.app.
  • Expanded README with install steps, API key setup, search strategy examples, and customization notes for new banks or competition radius.

Use cases

  • Market research — Compare branch density and customer satisfaction across banks and boroughs
  • Expansion planning — Identify underserved zones with low competition
  • Competitive intelligence — See which branches outperform nearby rivals on ratings and review volume
  • Academic / portfolio — Demonstrate end-to-end geodata extraction, analysis, and visualization

Blog

recent-work

Building Galena AI

Synthetic voice detection dashboard — six ONNX detectors behind a FastAPI service, verdict confidence, call history, and interactive model metrics.

Read more →

Galena AI

Synthetic voice detection dashboard — six ONNX detectors via FastAPI, verdict confidence, call history, and interactive model metrics.

How it was built →
border-home1