Re: Change the Nodata value in a file.


The `r+` trick is very neat for changing the metadata in-place.

But for actually changing the data values to match the new metadata, both your suggestions are fine - either used masked arrays or do the masking yourself. There is no smarter method and depending on your data type, you have to take care to get the masking right (or rely on `read(..., masked=True)` for it), e.g. for floating point comparison or NaN.

Btw, this question is ideal for Stack Overflow... -- in this case you could post and accept your own answer, though. :-D

Join to automatically receive all group messages.