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:01
Bash
ls -F /work
london_parks.fgb
0:24
Write
/work/solve.py
content · 54 lines · py
import geopandas as gpd
import json
def main():
# Load the parks data
gdf = gpd.read_file('london_parks.fgb')
# Assuming the area is in square meters or similar depending on the CRS.
# First, let's check the CRS and the geometry to be sure about the area calculation.
print(f"CRS: {gdf.crs}")
print(gdf.head())
# To calculate area in hectares correctly, we should work in a projected CRS (like EPSG:27700 for UK)
# if the data is in WGS84 or if it's not already in a metric system.
# Let's re-project to British National Grid (EPSG:27700) for area calculation
gdf_projected = gdf.to_crs(epsg=27700)
# Calculate area in hectares (1 hectare = 10,000 square meters)
# gdf_projected.area is in square meters
gdf['area_ha'] = gdf_projected.area / 10000.0
# Filter parks that are one hectare or more
large_parks = gdf[gdf['area_ha'] >= 1.0].copy()
# Metrics
count = len(large_parks)
total_area_ha = large_parks['area_ha'].sum()
# Bounding box on WGS84
# We need to take the subset and re-project it to WGS84 (EPSG:4326) to get the bbox
if not large_parks.empty:
large_parks_wgs84 = large_parks.to_crs(epsg=4326)
bounds = large_parks_wgs84.total_bounds # [xmin, ymin, xmax, ymax]
bbox_wgs84 = bounds.tolist()
else:
bbox_wgs84 = []
# Output results
summary = {
"count": int(count),
"total_area_ha": float(total_area_ha),
"bbox_wgs84": bbox_wgs84
}
with open('parks_summary.json', 'w') as f:
json.dump(summary, f, indent=4)
print("Summary created successfully.")
print(summary)
if __name__ == "__main__":
main()
Wrote /work/solve.py (1728 chars).
0:25
Bash
python /work/solve.py
CRS: EPSG:27700
id ... geometry
0 2b746b97-b0ed-35cc-8eb2-28a64821d7d8 ... MULTIPOLYGON (((532381.849 178719.026, 532391....
1 669c73cb-2314-3f8b-9b24-14b7db998247 ... MULTIPOLYGON (((532435.728 178838.472, 532437....
2 bcdbe219-4769-3d9a-bec6-ba44b2f4301f ... MULTIPOLYGON (((532657.956 178707.481, 532664....
3 6cb3b89b-4f9b-3a9d-b011-504239533b00 ... MULTIPOLYGON (((532863.795 178778.075, 532901....
4 7f18bab8-e6fc-34fa-a945-d784358559bd ... MULTIPOLYGON (((532724.97 178944.094, 532756.2...
[5 rows x 4 columns]
Summary created successfully.
{'count': 42, 'total_area_ha': 519.1620805430861, 'bbox_wgs84': [-0.19932378751294652, 51.49147199538401, -0.08248178747996572, 51.54706589542573]}
0:27
Bash
cat /work/parks_summary.json
{
"count": 42,
"total_area_ha": 519.1620805430861,
"bbox_wgs84": [
-0.19932378751294652,
51.49147199538401,
-0.08248178747996572,
51.54706589542573
]
}
0:36