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
london_parks.fgb
0:09
Write
/work/solve.py
content · 60 lines · py
import geopandas as gpd
import json
def main():
# Load the data
gdf = gpd.read_file('london_parks.fgb')
# Print info to inspect columns and CRS
print("Columns:", gdf.columns.tolist())
print("CRS:", gdf.crs)
print("Head:\n", gdf.head())
# Check for area column or calculate it
# Area calculation depends on CRS. If it's WGS84 (epsg:4326), we need to project it first.
# Determine if there is an 'area' column. If not, we'll calculate it.
# Let's assume we need to calculate it in hectares.
# Project to a suitable projected CRS if not already projected (e.g., British National Grid EPSG:27700)
# Or just use a metric CRS for area calculations.
if gdf.crs.is_geographic:
# Project to British National Grid for accurate area in meters
gdf_projected = gdf.to_crs(epsg=27700)
else:
gdf_projected = gdf.copy()
# Calculate area in square meters, then convert to hectares (1 ha = 10,000 m^2)
gdf_projected['area_ha'] = gdf_projected.geometry.area / 10000.0
# Filter parks >= 1 hectare
large_parks = gdf_projected[gdf_projected['area_ha'] >= 1.0].copy()
# Count
count = len(large_parks)
# Total area in hectares
total_area_ha = large_parks['area_ha'].sum()
# Bounding box on WGS84
# Project back to WGS84 to get bbox in degrees
large_parks_wgs84 = large_parks.to_crs(epsg=4326)
bounds = large_parks_wgs84.total_bounds # [xmin, ymin, xmax, ymax]
bbox_wgs84 = bounds.tolist()
# Prepare output
output = {
"count": int(count),
"total_area_ha": float(total_area_ha),
"bbox_wgs84": bbox_wgs84
}
with open('parks_summary.json', 'w') as f:
json.dump(output, f, indent=4)
print("\nSummary:")
print(output)
if __name__ == "__main__":
main()
Wrote /work/solve.py (1841 chars).
0:11
Bash
python /work/solve.py
Columns: ['id', 'name', 'class', 'geometry']
CRS: EPSG:27700
Head:
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:
{'count': 42, 'total_area_ha': 519.1620805430861, 'bbox_wgs84': [-0.19932378751294652, 51.49147199538401, -0.08248178747996572, 51.54706589542573]}
0:13
Bash
ls -F
london_parks.fgb parks_summary.json solve.py
0:30