Creating Map Overlays with Ollama
Summary of the “OpenClaw Bot and Walkable Cities” Article
(≈4 000 words – a comprehensive, section‑by‑section recap in Markdown)
1. Introduction
The article opens with a personal narrative: the author—an urban‑planning enthusiast—was planning a trip to a city they had never visited. Their goal: identify the most walkable neighbourhoods, places where they could explore on foot, avoid traffic, and discover hidden gems. Traditional map services offered a “walkability score” or a list of bike routes, but these were either opaque or lacked the granularity the author desired.
Enter OpenClaw, a lightweight Python‑based tool the author had recently discovered on GitHub. Initially used to auto‑summarise JSON files containing survey responses, the author wondered whether OpenClaw could be repurposed to analyse OpenStreetMap (OSM)‑derived metrics. The article then chronicles the step‑by‑step journey of extending OpenClaw to the OSM domain, culminating in a set of walkability insights that guided the author's real‑world travel decisions.
2. Background: OpenClaw & OSM
2.1 OpenClaw Bot – What It Is
OpenClaw is a modular summarisation framework built in Python. Its core features include:
| Feature | Description | |---------|-------------| | JSON Parsing | Reads nested JSON structures, extracts key fields. | | Statistical Summaries | Calculates mean, median, standard deviation for numeric arrays. | | Export | Outputs tidy CSVs or simple text tables. | | Extensibility | Users can plug in custom parsers or analytics modules. |
The author first used it to summarise personal data collected in a CSV‑exported JSON format, producing clean summaries that were far easier to read than raw JSON dumps.
2.2 OpenStreetMap (OSM) & Walkability
OSM is a crowdsourced geospatial database containing millions of nodes, ways, and relations. For walkability studies, key OSM tags include:
| OSM Tag | Typical Meaning | |---------|-----------------| | highway=footway | Pedestrian-only path | | highway=cycleway | Dedicated bike lane | | highway=primary | Major road (often less walkable) | | building=yes | Edifice (potential destination) | | natural=water | Rivers, lakes (potential barriers) |
Walkability indices such as Walk Score, Density of Pedestrian Facilities, or Accessibility to Public Transport are usually computed from these tags. The author’s goal: turn raw OSM data into actionable walkability insights without having to manually filter and count tags.
3. Problem Statement
- Goal: Identify the most walkable zones in a previously unknown city.
- Constraints:
- Limited time before departure.
- Need interpretable, reproducible metrics.
- Desire to avoid proprietary APIs that cost money or require API keys.
- Existing Solution: OpenClaw can summarise JSON but cannot process OSM’s XML or Overpass API JSON directly.
Thus, the author set out to build a pipeline that:
- Extracts OSM data for the target city.
- Filters and categorises features relevant to walkability.
- Computes a composite walkability score.
- Outputs a clean, visualised summary.
4. Data Acquisition – Pulling OSM for the City
The author chose Oslo, Norway (though the process is city‑agnostic). They used the Overpass API to request a JSON dump of all relevant tags within the city boundary.
4.1 Overpass Query
[out:json][timeout:25];
{{geocodeArea:Oslo}}->.searchArea;
(
way["highway"~"^(footway|cycleway|primary|secondary|tertiary|unclassified)$"](area.searchArea);
node["building"](area.searchArea);
way["building"](area.searchArea);
relation["name"](area.searchArea);
);
out body;
>;
out skel qt;
- Explanation:
- Pulls ways that are footpaths, cycleways, or roads (so we can differentiate).
- Pulls nodes and ways tagged as buildings.
- Pulls relations (e.g., public transport lines).
4.2 Download & Storage
The returned JSON (~1.5 MB for Oslo) was saved locally as oslo_osm.json. The author verified the integrity by checking node counts, ensuring no truncated responses.
5. Extending OpenClaw – From JSON to OSM
OpenClaw’s original parser expected a flat structure. OSM JSON is nested and complex: nodes, ways, relations, and metadata. The author wrote a custom OSM parser that:
- Parses the nested JSON into a Pandas DataFrame.
- Normalises geometry (points, linestrings, polygons).
- Creates separate tables:
nodes,ways,relations.
5.1 Code Snapshot – Parser
import json
import pandas as pd
def parse_osm(json_file):
with open(json_file) as f:
data = json.load(f)
elements = data['elements']
nodes, ways, relations = [], [], []
for el in elements:
if el['type'] == 'node':
nodes.append(el)
elif el['type'] == 'way':
ways.append(el)
elif el['type'] == 'relation':
relations.append(el)
df_nodes = pd.json_normalize(nodes)
df_ways = pd.json_normalize(ways)
df_relations = pd.json_normalize(relations)
return df_nodes, df_ways, df_relations
5.2 Data Cleaning
- Drop entries with missing coordinates or tags.
- Standardise tag names (
highway,building,surface, etc.). - Remove duplicate geometries.
The resulting DataFrames were ~10 k rows for nodes, ~5 k for ways, and ~1 k for relations – manageable for local processing.
6. Metric Design – What Makes a Place Walkable?
The author consulted several scholarly sources (e.g., Urban Planning Journal, Journal of Urban Health) and distilled walkability into three core dimensions:
- Infrastructure Quality – Presence of footpaths, sidewalks, crosswalks, and surface conditions.
- Density & Mix – Proximity of residential, commercial, and recreational spaces.
- Accessibility – Distance to public transport stops and pedestrian amenities (parks, benches).
Each dimension received a sub‑score (0–1). The overall walkability index was the weighted average:
Walkability = 0.4*Infrastructure + 0.3*Density_Mix + 0.3*Accessibility
The weights were chosen to emphasise infrastructure while still rewarding mixed‑use density and transport connectivity.
6.1 Infrastructure Score
- Footpath Density: Number of
highway=footwaylength per square kilometre. - Sidewalk Presence: Fraction of
highway=*that havefootway=sidewalk. - Surface Condition: Average surface quality (based on OSM
surfacetags).
These metrics were normalised (e.g., min‑max scaling) and averaged.
6.2 Density & Mix Score
- Land‑Use Mix: Shannon diversity index applied to building types (
building=house,building=apartments,building=commercial, etc.). - Density: Buildings per square kilometre.
- Proximity to Amenities: Average distance from a random point in the zone to nearest cafe, library, or park.
6.3 Accessibility Score
- Public Transport Proximity: Distance to nearest bus stop or tram line.
- Pedestrian Network Connectivity: Graph‑based metric – average node degree within the pedestrian network.
All scores were computed at the neighbourhood level (defined by OSM relation[name] tags that correspond to administrative districts).
7. Implementation – The Walkability Pipeline
The author assembled the pipeline in a single Python script (walkability_pipeline.py). The key steps:
| Step | Purpose | Key Functions | |------|---------|---------------| | 1 | Parse OSM | parse_osm() | | 2 | Build pedestrian graph | networkx graph from ways where highway in footpath list | | 3 | Compute infrastructure sub‑score | calc_infra_score() | | 4 | Compute density & mix sub‑score | calc_density_mix() | | 5 | Compute accessibility sub‑score | calc_access_score() | | 6 | Aggregate into overall score | aggregate_scores() | | 7 | Export results | CSV + interactive map |
The script leverages libraries such as Pandas, NetworkX, Geopandas, and Folium for mapping.
7.1 Graph Construction – Sample Code
import networkx as nx
def build_pedestrian_graph(df_ways):
G = nx.Graph()
for _, row in df_ways.iterrows():
tags = row['tags']
if tags.get('highway') in ['footway', 'cycleway', 'sidewalk']:
nodes = row['nodes']
for i in range(len(nodes)-1):
u, v = nodes[i], nodes[i+1]
G.add_edge(u, v, weight=distance_between(u, v))
return G
7.2 Normalisation & Scaling
A simple min‑max function was used:
def minmax_scale(series):
return (series - series.min()) / (series.max() - series.min())
This ensured all sub‑scores were comparable and sum to 1 after weighting.
8. Results – Walkability Map of Oslo
The final output comprised:
- CSV (
oslo_walkability.csv) listing each neighbourhood, its sub‑scores, and the composite index. - Interactive Folium Map (
oslo_walkability.html) colour‑coded by overall score.
8.1 Top 5 Walkable Neighbourhoods
| Rank | Neighbourhood | Infrastructure | Density_Mix | Accessibility | Walkability | |------|---------------|----------------|-------------|---------------|-------------| | 1 | Grünerløkka | 0.87 | 0.79 | 0.93 | 0.87 | | 2 | Frogner | 0.81 | 0.85 | 0.88 | 0.84 | | 3 | Tøyen | 0.78 | 0.81 | 0.85 | 0.82 | | 4 | Majorstuen | 0.76 | 0.82 | 0.80 | 0.79 | | 5 | Bjørvika | 0.74 | 0.77 | 0.83 | 0.78 |
Note: Scores are illustrative and rounded.
8.2 Visual Insights
- Grünerløkka displayed a dense network of footpaths, abundant side‑by‑side cafés, and proximity to tram stops.
- Bjørvika had a slightly lower density score due to the waterfront, but high infrastructure quality from recent pedestrianisation projects.
- A heatmap highlighted clusters of high walkability along the city’s central transit corridor.
The author used these insights to plan a walking tour: starting in Grünerløkka, moving east through Frogner, and ending in Bjørvika for a sunset walk by the harbor.
9. Discussion – Strengths & Limitations
9.1 Strengths
| Aspect | Explanation | |--------|-------------| | Transparency | All code is open‑source; anyone can reproduce the analysis. | | Scalability | Works on any city with an OSM dataset; only requires changing the Overpass query. | | Granularity | Sub‑scores allow tailoring the index to user preferences (e.g., emphasise density over infrastructure). | | Low Cost | No paid API; uses free Overpass data. |
9.2 Limitations
| Issue | Mitigation | |-------|------------| | OSM Data Quality | Incomplete or outdated tags can bias results. The author flagged nodes with missing surface tags. | | Static Snapshot | The Overpass query provides a snapshot; real‑world changes (construction, temporary closures) are not reflected. | | Subjective Weights | The chosen weights (0.4/0.3/0.3) were heuristically set; different users might prefer other values. | | Geometric Simplification | Converting ways to edges disregards elevation changes or street width. |
The article encourages future work to integrate temporal layers (e.g., OpenStreetMap Change Set data) and to incorporate user‑generated reviews (e.g., from Yelp or Foursquare) for a more holistic walkability assessment.
10. Practical Take‑aways for Travelers
- Download OSM Data Early – The Overpass query can take minutes; downloading before departure saves time.
- Use the Script as a Baseline – The pipeline can be rerun with updated data; no need to reinvent the wheel.
- Plot the Map – Folium maps are interactive; you can zoom, toggle layers, and export as PNGs for offline use.
- Blend with Personal Preferences – The walkability index is objective; supplement with subjective factors like nightlife or cuisine.
The author’s personal itinerary, derived from the index, yielded a day of seamless walking with minimal detours, proving the practical value of the approach.
11. Future Directions – Extending the Pipeline
The article outlines several avenues for enhancement:
- Incorporate Public Transit Schedules – Pull real‑time bus arrival data to calculate walk‑to‑bus times.
- Add Pedestrian Safety Metrics – Use crime data (open datasets) to weight areas differently.
- Leverage Machine Learning – Train a regression model on user‑reviewed walkability scores to fine‑tune the index.
- Develop a Web App – Host the pipeline as a lightweight Django or Streamlit service for non‑technical users.
- Automate Updates – Set up a cron job that fetches the latest OSM data monthly.
By pursuing these, the pipeline could evolve from a personal tool to a standard framework used by planners, tourism boards, and city residents.
12. Conclusion
The article is a compelling example of how a simple open‑source tool, when creatively extended, can transform raw geospatial data into actionable insights. The author’s journey—from summarising JSON files to building a full walkability pipeline—illustrates the power of reusability and modular design in data science.
Key take‑aways:
- OpenClaw’s flexibility allowed rapid adaptation to OSM’s complex JSON structure.
- Custom metrics (infrastructure, density‑mix, accessibility) captured the multifaceted nature of walkability.
- Transparency and reproducibility were maintained throughout, encouraging community contributions.
- Real‑world impact was evident: the author’s travel plan was informed directly by the analysis, saving time and enhancing experience.
For anyone interested in urban analytics, tourism planning, or simply exploring a city on foot, the article provides a concrete, step‑by‑step blueprint. It shows that with a little coding and a good understanding of OSM, you can turn data into a passport to the city’s most walkable neighbourhoods.