crs-l2-svalbard-polar-areas

Status: done
Score: 94
Duration: 2:13
Cost: 0.23¢
Model: google/gemma-4-26b-a4b-it

Map (reference ← swipe → agent)

0:00
svalbard_glaciers — I need an honest size ranking of these high-latitude glaciers using true geographic area, not the distorted values you'd get from raw lat/lon coordinates. Pick the most appropriate coordinate system for measuring area at these latitudes and give me the top 20 by area as CSV: columns name, area_km2, bbox_minx_polar, bbox_miny_polar, bbox_maxx_polar, bbox_maxy_polar, crs_epsg — bboxes in the same projected metres as the area, and crs_epsg the integer EPSG code of the CRS you used. Sort by area_km2 descending. File: svalbard_glaciers_top20.csv.
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
svalbard_glaciers_wgs84.gpkg
0:03
Read svalbard_glaciers_wgs84.gpkg
binary file: svalbard_glaciers_wgs84.gpkg contains NUL bytes. Use a domain tool to inspect it (duckdb, geopandas, pyogrio, sqlite3, ...).
0:08
Write /work/inspect_data.py
content · 15 lines · py
import geopandas as gpd

def inspect_gpkg(path):
    try:
        gdf = gpd.read_file(path)
        print(f"Shape: {gdf.shape}")
        print(f"CRS: {gdf.crs}")
        print(f"Columns: {gdf.columns.tolist()}")
        print(f"First 5 rows:\n{gdf.head()}")
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    inspect_gpkg('svalbard_glaciers_wgs84.gpkg')
Wrote /work/inspect_data.py (391 chars).
0:14
import geopandas as gpd

def inspect_gpkg(path):
    try:
        gdf = gpd.read_file(path)
        print(f"Shape: {gdf.shape}")
        print(f"CRS: {gdf.crs}")
        print(f"Columns: {gdf.columns.tolist()}")
        print(f"First 5 rows:\n{gdf.head()}")
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    inspect_gpkg('svalbard_glaciers_wgs84.gpkg')
0:14
Bash python /work/inspect_data.py
Shape: (169, 5)
CRS: EPSG:4326
Columns: ['id', 'name', 'subtype', 'class', 'geometry']
First 5 rows:
                                     id  ...                                           geometry
0  af2fac62-8f17-35dd-bb4b-cd7ac5f906b0  ...  MULTIPOLYGON (((22.78865 80.14451, 22.73235 80...
1  12ba70b6-6f49-35fa-a072-bfdc8321c987  ...  MULTIPOLYGON (((14.02517 77.97816, 14.02557 77...
2  5919887f-cdb2-3283-a884-b1146bdda8ee  ...  MULTIPOLYGON (((16.06338 78.22499, 16.06381 78...
3  cdbc3ec1-ce56-3dbc-89fe-f4bce34bd5a8  ...  MULTIPOLYGON (((12.92179 78.40649, 12.95164 78...
4  81e675dd-427e-3cd8-ac05-929fbbd3c30e  ...  MULTIPOLYGON (((11.88304 78.88352, 11.88399 78...

[5 rows x 5 columns]
1:24
Write /work/solve.py
content · 57 lines · py
import geopandas as gpd
import pandas as pd

def solve():
    # Load the data
    input_file = 'svalbard_glaciers_wgs84.gpkg'
    gdf = gpd.read_file(input_file)

    # Svalbard is located at high latitudes (roughly 74 to 81 N).
    # For accurate area measurements in Svalbard, North Pole Stereographic 
    # projection is often preferred. 
    # EPSG:3413 is NSIDC Sea Ice Polar Stereographic North.
    # EPSG:3031 is ETRS89-extended / LAEA Europe, which is good for Europe.
    # Let's use EPSG:3413 (North Polar Stereographic) as it's designed for the poles.
    # Another option is EPSG:3411 or similar, but 3413 is very standard for arctic.
    # Actually, let's check if there's a local Svalbard specific one or just use 
    # a standard Polar Stereographic.
    
    target_crs = 'EPSG:3413'
    
    # Project to the chosen CRS
    gdf_projected = gdf.to_crs(target_crs)
    
    # Calculate area in square meters, then convert to km2
    gdf_projected['area_km2'] = gdf_projected.geometry.area / 10**6
    
    # Get top 20 by area
    top_20 = gdf_projected.sort_values(by='area_km2', ascending=False).head(20).copy()
    
    # Calculate bboxes in the projected CRS
    # bbox is (minx, miny, maxx, maxy)
    top_20['bbox_minx_polar'] = top_20.geometry.bounds.minx
    top_20['bbox_miny_polar'] = top_20.geometry.bounds.miny
    top_20['bbox_maxx_polar'] = top_20.geometry.bounds.maxx
    top_20['bbox_maxy_polar'] = top_20.geometry.bounds.maxy
    
    # The EPSG code of the projection used
    epsg_code = int(target_crs.split(':')[-1])
    top_20['crs_epsg'] = epsg_code
    
    # Select and rename columns for output
    # Requirements: name, area_km2, bbox_minx_polar, bbox_miny_polar, bbox_maxx_polar, bbox_maxy_polar, crs_epsg
    output_columns = [
        'name', 'area_km2', 'bbox_minx_polar', 'bbox_miny_polar', 
        'bbox_maxx_polar', 'bbox_maxy_polar', 'crs_epsg'
    ]
    
    final_df = top_20[output_columns]
    
    # Write to CSV
    output_file = 'svalbard_glaciers_top20.csv'
    final_df.to_csv(output_file, index=False)
    print(f"Successfully saved top 20 glaciers to {output_file}")

if __name__ == "__main__":
    solve()
Wrote /work/solve.py (2171 chars).
1:27
Bash python /work/solve.py
Successfully saved top 20 glaciers to svalbard_glaciers_top20.csv
1:31
Bash head -n 5 svalbard_glaciers_top20.csv
name,area_km2,bbox_minx_polar,bbox_miny_polar,bbox_maxx_polar,bbox_maxy_polar,crs_epsg
Sørfonna,4146.995028319491,1018600.817882212,-472800.3912665622,1093407.1674378568,-365990.2909299612,3413
Vestfonna,2272.1831167032924,955923.9805055511,-493366.30464676005,1014589.5375176889,-420978.1660846758,3413
Åsgardfonna,872.2491860794605,970672.3159938941,-558393.7394266115,1024973.2110542867,-525034.1001042881,3413
Kvitøyjøkulen,595.2771582678471,1028269.5074980733,-251073.05692732212,1052280.1255731431,-211860.17370643766,3413
1:34
Bash ls -l svalbard_glaciers_top20.csv
-rw-r--r-- 1 agent agent 2303 Jun 18 09:50 svalbard_glaciers_top20.csv
2:11