I've created a mask over a vector shapefile and have then created another one which zooms in to the relevant area. The problem I have with this new mask is that the masked area is the bit that I want, so I need to invert it somehow. (Note that I imported numpy as np)
This is the code I used for the 2nd mask:
catchment_mask = gmask[minrow:minrow+nrow, mincol:mincol+ncol]
catchment_mask = np.where(catchment_mask == 1, 1., np.nan)
I've tried using this code to invert it but it has applied a mask to the entire area:
inverse_catchment_mask = (np.logical_not(catchment_mask))
I'd be really grateful for any suggestions!
np.ma, MaskedArray subclass, but I don't think that's what you have. It looks like yourmaskis a slice ofgmask, but then you make a new array usingwhere. Why? That's no longer aview. Why thenp.nan?logical_notof that isFalse.