dartobsgen.polygon_from_netcdf_mask#
- dartobsgen.polygon_from_netcdf_mask(nc_file, mask_var, lat_var, lon_var)[source]#
Extract the boundary of a 2D 0/1 mask and return a shapely Polygon.
Contours the mask at level 0.5 using
skimage.measure.find_contours. If multiple contours are found the one with the most vertices is used (i.e. the largest boundary).- Parameters:
- Return type:
shapely.geometry.Polygon
- Raises:
ValueError – If no contour is found in the mask.