Open arielze opened 6 years ago
The fact that r2c.to_png() == r1c.to_png()
is just a coincidence. The default value of in_range
parameter of to_png
method is dtype
so it is equivalent to:
>> r1c.to_png(in_range='dtype') == r2c.to_png(in_range='dtype')
True
to_png
method calls internally astype
, but if we look closer at the images we are getting with astype
:
>>> r1c.astype(np.uint8, in_range='dtype').image
masked_array(
data=[[[127, 127],
[127, 127]]],
mask=False,
fill_value=63,
dtype=uint8)
>>>
>>> r2c.astype(np.uint8, in_range='dtype').image
masked_array(
data=[[[127, 127],
[127, 127]]],
mask=False,
fill_value=63,
dtype=uint8)
we can see that using astype
with in_range='dtype'
converts all pixel values to the same value (127).
The correct way to compare two images is (which as expected returns False
):
>>> r2c.to_png(in_range='image') == r1c.to_png(in_range='image')
False
It turn out that we still lack of the way to compare two georasters with flipped images.
There are cases when two rasters have the same information, but comparing them returns
False
, for example:Here is a code example: