Skip to content

Instantly share code, notes, and snippets.

@nilsleh
Created November 25, 2025 18:30
Show Gist options
  • Select an option

  • Save nilsleh/6f5ba8a4817af8d0442366f238ded179 to your computer and use it in GitHub Desktop.

Select an option

Save nilsleh/6f5ba8a4817af8d0442366f238ded179 to your computer and use it in GitHub Desktop.
fix antimeridian plotting of SWOT tracks
import geopandas as gpd
import shapely
import antimeridian
def fix_antimeridian(gdf):
def fix_geom(geom):
if geom.geom_type == 'Polygon':
return antimeridian.fix_polygon(geom)
elif geom.geom_type == 'MultiPolygon':
return antimeridian.fix_multi_polygon(geom)
return geom
result = gdf.copy()
result['geometry'] = result['geometry'].apply(fix_geom)
return result
df = dataset.read(0).read(0)
df["geometry"] = df["istac:spatial"].apply(shapely.from_wkb)
gdf = gpd.GeoDataFrame(df, geometry="geometry", crs="EPSG:4326")
gdf = fix_antimeridian(gdf)
gdf.plot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment