44from datetime import datetime
55from typing import Dict , List , Tuple
66
7+ import cartopy .crs as ccrs
78import geopandas as gpd
89import matplotlib .pyplot as plt
910import numpy as np
1819from shapely .geometry import Polygon , mapping
1920from shapely .ops import transform
2021from shapely .vectorized import contains
21- import cartopy .crs as ccrs
2222
2323
24- def plot_mesh_edge (
25- msh_t : jigsaw_msh_t ,
26- ax = None ,
27- to_geo = None ,
28- ** kwargs
29- ) -> None :
24+ def plot_mesh_edge (msh_t : jigsaw_msh_t , ax = None , to_geo = None , ** kwargs ) -> None :
3025 """
3126 Plots the edges of a triangular mesh on a given set of axes.
3227
@@ -43,8 +38,6 @@ def plot_mesh_edge(
4338 **kwargs : keyword arguments, optional
4439 Additional keyword arguments passed to the `triplot` function.
4540 These can be used to customize the plot (e.g., color, line style).
46-
47-
4841 """
4942
5043 crd = np .array (msh_t .vert2 ["coord" ], copy = True )
@@ -156,9 +149,11 @@ def plot_bathymetry(rasters_path: List[str], polygon: Polygon, ax: Axes) -> Axes
156149 height , width = data [0 ].shape
157150 cols , rows = np .meshgrid (np .arange (width ), np .arange (height ))
158151 xs , ys = rasterio .transform .xy (transform , rows , cols )
159-
152+
160153 im = ax .imshow (
161- data [0 ], cmap = "gist_earth" , extent = (np .min (xs ), np .max (xs ), np .min (ys ), np .max (ys ))
154+ data [0 ],
155+ cmap = "gist_earth" ,
156+ extent = (np .min (xs ), np .max (xs ), np .min (ys ), np .max (ys )),
162157 )
163158 cbar = plt .colorbar (im , ax = ax )
164159 cbar .set_label ("Depth (m)" )
@@ -168,6 +163,7 @@ def plot_bathymetry(rasters_path: List[str], polygon: Polygon, ax: Axes) -> Axes
168163 gl = ax .gridlines (draw_labels = True )
169164 gl .top_labels = False
170165 gl .right_labels = False
166+
171167 return ax
172168
173169
@@ -302,13 +298,15 @@ def plot_boundaries(mesh: jigsaw_msh_t, ax: Axes, to_geo=None) -> Axes:
302298 A function to transform coordinates from projected to geographic CRS.
303299 """
304300
305- plot_mesh_edge (mesh .msh_t ,to_geo = to_geo , ax = ax , color = "gray" , lw = 0.5 )
301+ plot_mesh_edge (mesh .msh_t , to_geo = to_geo , ax = ax , color = "gray" , lw = 0.5 )
306302
307303 def plot_boundary (gdf , color , label ):
308304 try :
309305 if to_geo :
310306 gdf = gdf .copy ()
311- gdf ["geometry" ] = gdf ["geometry" ].apply (lambda geom : transform (to_geo , geom ))
307+ gdf ["geometry" ] = gdf ["geometry" ].apply (
308+ lambda geom : transform (to_geo , geom )
309+ )
312310 gdf .plot (ax = ax , color = color , label = label )
313311 except Exception as e :
314312 print (f"No { label } boundaries available. Error: { e } " )
@@ -321,7 +319,7 @@ def plot_boundary(gdf, color, label):
321319 ax .legend ()
322320
323321
324- def plot_bathymetry_interp (mesh : jigsaw_msh_t ,to_geo , ax : Axes ) -> Axes :
322+ def plot_bathymetry_interp (mesh : jigsaw_msh_t , to_geo , ax : Axes ) -> Axes :
325323 """
326324 Plots the interpolated bathymetry data on a mesh.
327325
@@ -342,7 +340,7 @@ def plot_bathymetry_interp(mesh: jigsaw_msh_t,to_geo, ax: Axes) -> Axes:
342340
343341 im = ax .tricontourf (
344342 Triangulation (
345- crd [:, 0 ],
343+ crd [:, 0 ],
346344 crd [:, 1 ],
347345 triangles = mesh .msh_t .tria3 ["index" ],
348346 ),
@@ -356,6 +354,7 @@ def plot_bathymetry_interp(mesh: jigsaw_msh_t,to_geo, ax: Axes) -> Axes:
356354 cbar .set_label ("Depth (m)" )
357355 ax .set_extent ([* bnd ], crs = ccrs .PlateCarree ())
358356
357+
359358def simply_polygon (base_shape : Polygon , simpl_UTM : float , project ) -> Polygon :
360359 """
361360 Simplifies a polygon by transforming it to a projected coordinate system (e.g., UTM),
0 commit comments