Rasterizing polygon from numpy arrays


I've been struggling with this for quite some time now, so its time to ask for help.

My problem is set up as follows:
I want to create a binary mask for an image that is quite large (~10k rows and 360 columns). I have several polygons, all closed, and I want to assign all values that fall in the polygons as True.
The polygons are in the form of a numpy array, with (x,y) coordinates. Each polygon has roughly 1000 values. I have about 200 such polygons for a given image.
Ideally, since the polygons are quite small, I should not query all points of the image (as suggested for example here https://stackoverflow.com/questions/36399381/whats-the-fastest-way-of-checking-if-a-point-is-inside-a-polygon-in-python)

I found documentation about how to rasterize shapefiles here https://rasterio.readthedocs.io/en/latest/api/rasterio.features.html
using for example
rasterio.features.geometry_mask(geometries, out_shape, transform, all_touched=False, invert=False)
but I could not figure out how to do this with a simple numpy array.

Is it possible?

I should also mention that my image axes are mixed. The vertical axis is a float (depths, from 0m to ~100m at 1 mm spacing) while the horizontal axis contains integers (angles, from 0 to 360 in 1 degree increments).

But I could also change these to be simply indices (both integers).

Thank you for any feedback!

Join main@rasterio.groups.io to automatically receive all group messages.