[Python] Having white boundary when plotting a masked map, and then overlay the mask with grey...

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    So I am seeing a white boundary when plotting a masked map, and then overlay the mask with grey color:

    def apply_mask(result_raster, mask):
    return np.where(mask, np.nan, result_raster)

    masked_result_raster = apply_mask(result_raster, mask)

    flipped_mask = np.where(mask == 1, 0, 1)

    plot_raster_with_colorbar(ax, masked_result_raster, cmap, norm, (bounds[0], bounds[2], bounds[1], bounds[3]), boundaries)

    ax.imshow(flipped_mask, cmap=gray_cmap, alpha=0.6, extent=(bounds[0], bounds[2], bounds[1], bounds[3]))

    plt.show()


    How should I fix it?

    I also tried directly plot the polygons which is the mask

    polygons.plot(ax=ax, color='gray', edgecolor='none')


    but still having white boundary

    Continue reading...

Compartilhe esta Página