dd-l1-london-parks-count
Map (reference ← swipe → agent)
0:00
I've got inner-London parks (london_parks) and I'm sizing the corpus before commissioning a green-space accessibility study. How many of those parks come in at one hectare or more, what's their combined area in hectares, and what bounding box would I draw around that subset on a WGS84 map? Output parks_summary.json with keys count, total_area_ha, and bbox_wgs84 (as a [xmin, ymin, xmax, ymax] array).
0:00
System info
{
"adapter": "openrouter",
"model": "google/gemma-4-26b-a4b-it",
"base_url": "https://openrouter.ai/api/v1"
}
0:03
Bash
ls -F
london_parks.fgb
0:18
Write
/work/solve.py
content · 52 lines · py
import geopandas as gpd
import json
def main():
# Load the parks
parks = gpd.read_file('london_parks.fgb')
# Assuming the geometry is in a projected CRS or we need to handle area calculation carefully.
# Let's check the CRS first.
print(f"Original CRS: {parks.crs}")
# We need area in hectares. 1 hectare = 10,000 square meters.
# To get accurate area, we should project to a metric CRS if not already.
# EPSG:27700 (OSGB 1936 / British National Grid) is standard for UK.
if parks.crs.is_geographic:
parks_metric = parks.to_crs(epsg=27700)
else:
parks_metric = parks.copy()
# Calculate area in square meters, then convert to hectares
parks_metric['area_ha'] = parks_metric.geometry.area / 10000.0
# Filter for parks >= 1 hectare
large_parks = parks_metric[parks_metric['area_ha'] >= 1.0].copy()
# Count
count = len(large_parks)
# Total area in hectares
total_area_ha = large_parks['area_ha'].sum()
# Bounding box in WGS84
# Transform large_parks back to WGS84 for the bbox
large_parks_wgs84 = large_parks.to_crs(epsg=4326)
bounds = large_parks_wgs84.total_bounds # [xmin, ymin, xmax, ymax]
# Prepare output
output = {
"count": int(count),
"total_area_ha": float(total_area_ha),
"bbox_wgs84": [float(b) for b in bounds]
}
with open('parks_summary.json', 'w') as f:
json.dump(output, f, indent=4)
print(f"Summary created: {output}")
if __name__ == "__main__":
main()
Wrote /work/solve.py (1586 chars).
0:19
Bash
python solve.py
Original CRS: EPSG:27700
Summary created: {'count': 42, 'total_area_ha': 519.1620805430861, 'bbox_wgs84': [-0.19932378751294652, 51.49147199538401, -0.08248178747996572, 51.54706589542573]}
0:27
Bash
ls -F
london_parks.fgb parks_summary.json solve.py
0:28
Read
/work/parks_summary.json
1 {
2 "count": 42,
3 "total_area_ha": 519.1620805430861,
4 "bbox_wgs84": [
5 -0.19932378751294652,
6 51.49147199538401,
7 -0.08248178747996572,
8 51.54706589542573
9 ]
10 }
0:32