Skip to content

Instantly share code, notes, and snippets.

View perrette's full-sized avatar

Mahé Perrette perrette

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@perrette
perrette / Raster mask on regular grid from shapely Polygon
Last active December 16, 2023 18:01
vector outline to raster mask
import numpy as np
def outline_to_mask(line, x, y):
"""Create mask from outline contour
Parameters
----------
line: array-like (N, 2)
x, y: 1-D grid coordinates (input for meshgrid)