[Python] rasterio - mask raster against shape, with all pixels completely inside shape

Discussão em 'Python' iniciado por Stack, Janeiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I'm cutting a tiff file against a given shape, to filter the pixels inside.

    I'm using rasterio to do it like this:

    mask = rasterio.mask.mask(tiff, geoms, crop=True, all_touched=False)

    This works but doesn't yield exactly what I want (which is: give me only the pixels that are completely inside the shape).

    [​IMG] see bigger picture

    So, what all_touched=False does is, according to the docs, that it restricts the criteria from all_touched=True (fig. 1) by only including pixels that have its center inside the shape (fig. 2).

    How can I select only the pixels that are completely inside the shape (like in fig. 3)?

    Continue reading...

Compartilhe esta Página