dd-l1-capetown-clinics-bbox
Map (reference ← swipe → agent)
0:00
I'm about to push the `capetown_clinics.csv` export through to our case-management system and I want a quick inventory check first. Can you produce a small JSON file with the total clinic count, the overall bounding box as a bbox array, and the count per subdistrict, so I can confirm every health subdistrict is represented? Please write it to `clinic_inventory.json` with keys `count`, `bbox`, and `count_per_subdistrict`.
0:00
System info
{
"adapter": "openrouter",
"model": "google/gemma-4-26b-a4b-it",
"base_url": "https://openrouter.ai/api/v1"
}
0:01
Bash
ls -F
capetown_clinics.csv
0:02
Read
capetown_clinics.csv
1 clinic_id,name,subdistrict,wkt_geom
2 1,Mokoena Western Clinic,Western,POINT(18.478309 -33.888756)
3 2,Ndlovu Western Clinic,Western,POINT(18.421127 -33.924929)
4 3,Pieterse Western Clinic,Western,POINT(18.389237 -33.976099)
5 4,van der Merwe Western Clinic,Western,POINT(18.47354 -33.890933)
0:16
Write
/work/solve.py
content · 43 lines · py
# /// script
# requires-python = ">=3.12"
# dependencies = ["pandas", "shapely"]
# ///
import pandas as pd
import json
from shapely import wkt
def main():
df = pd.read_csv('capetown_clinics.csv')
# Parse wkt_geom
df['geometry'] = df['wkt_geom'].apply(wkt.loads)
# Total count
total_count = len(df)
# Bounding box
# Combine all geometries into one multi-point for bbox calculation
all_geoms = df['geometry'].tolist()
if all_geoms:
from shapely.ops import unary_union
combined = unary_union(all_geoms)
bbox = list(combined.bounds) # [minx, miny, maxx, maxy]
else:
bbox = []
# Count per subdistrict
subdistrict_counts = df['subdistrict'].value_counts().to_dict()
# Output JSON
output = {
"count": total_count,
"bbox": bbox,
"count_per_subdistrict": subdistrict_counts
}
with open('clinic_inventory.json', 'w') as f:
json.dump(output, f, indent=4)
if __name__ == "__main__":
main()
Wrote /work/solve.py (1046 chars).
0:24
Bash
uv run solve.py
Installed 5 packages in 203ms
0:29
Read
clinic_inventory.json
1 {
2 "count": 80,
3 "bbox": [
4 18.380309,
5 -34.073855,
6 18.819549,
7 -33.701317
8 ],
9 "count_per_subdistrict": {
10 "Western": 12,
11 "Southern": 12,
12 "Tygerberg": 11,
13 "Northern": 10,
14 "Eastern": 10,
15 "Klipfontein": 9,
16 "Mitchells Plain": 8,
17 "Khayelitsha": 8
18 }
19 }
0:39