Created
November 25, 2025 18:30
-
-
Save nilsleh/6f5ba8a4817af8d0442366f238ded179 to your computer and use it in GitHub Desktop.
fix antimeridian plotting of SWOT tracks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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