Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Calving Fronts

ESA
import geopandas as gpd
import matplotlib.pyplot as plt
import pandas as pd

bucket = 's3://EarthCODE/'
endpoint_url = "https://s3.waw4-1.cloudferro.com"
region_name = "eu-west-2"
file = 'OSCAssets/polar_cube_datasets/calving_fronts/Antarctic_coastlines.parquet'
gdf = gpd.read_parquet(
    f"{bucket}{file}",
    storage_options={ "anon": True, 
                    "client_kwargs": {
                        "endpoint_url": endpoint_url,
                        "region_name": region_name
                    }
    }
)
gdf['area'] = gdf.area
largest_polygon = gdf.sort_values(['time', 'area'], ascending=False).groupby('time').first()
largest_polygon
Loading...
fronts = largest_polygon.reset_index().sort_values("time")
fronts["year"] = pd.to_datetime(fronts["time"]).dt.year

changed = fronts.geometry.iloc[0].symmetric_difference(fronts.geometry.iloc[-1])
zoom = max(getattr(changed, "geoms", [changed]), key=lambda geom: geom.area)
xmin, ymin, xmax, ymax = zoom.bounds
pad = max(xmax - xmin, ymax - ymin) * 0.25

ax = fronts.plot(
    column="year",
    cmap="plasma",
    alpha=0.12,
    edgecolor="black",
    linewidth=1,
    legend=True,
    figsize=(8, 8),
)

ax.set_xlim(xmin - pad, xmax + pad)
ax.set_ylim(ymin - pad, ymax + pad)
ax.set(title="Polygon shrinkage through time", aspect="equal")
ax.set_axis_off()
plt.show()
<Figure size 800x800 with 2 Axes>