Skip to content

Commit

Permalink
Fix raster_equal
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Mar 8, 2024
1 parent 09b1d56 commit cb521f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/source/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ documentation.
Raster.set_mask
Raster.set_nodata
Raster.get_nanarray
Raster.get_mask
Raster.subsample
```

Expand Down
7 changes: 4 additions & 3 deletions geoutils/raster/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ def raster_equal(self, other: RasterType) -> bool:
[
np.array_equal(self.data.data, other.data.data, equal_nan=True),
# Use getmaskarray to avoid comparing boolean with array when mask=False
np.array_equal(np.ma.getmaskarray(self.data.mask), np.ma.getmaskarray(other.data.mask)),
np.array_equal(np.ma.getmaskarray(self.data), np.ma.getmaskarray(other.data)),
self.data.fill_value == other.data.fill_value,
self.data.dtype == other.data.dtype,
self.transform == other.transform,
Expand Down Expand Up @@ -3506,7 +3506,8 @@ def to_pointcloud(
Optionally, all other bands can also be stored in columns "b1", "b2", etc. For more specific band selection,
use Raster.split_bands previous to converting to point cloud.
Optionally, randomly subsample valid pixels of the data band (nodata values are skipped).
Optionally, randomly subsample valid pixels for the data band (nodata values are skipped, but only for the band
that will be used as data column of the point cloud).
If 'subsample' is either 1, or is equal to the pixel count, all valid points are returned.
If 'subsample' is smaller than 1 (for fractions), or smaller than the pixel count, a random subsample
of valid points is returned.
Expand Down Expand Up @@ -3544,7 +3545,7 @@ def to_pointcloud(
if data_band != 1 and data_column_name == "b1":
data_column_name = "b" + str(data_band)

# The valid mask is considered only for the data band
# We do 2D subsampling on the data band only, regardless of valid masks on other bands
if self.is_loaded:
if self.count == 1:
self_mask = get_mask_from_array(self.data) # This is to avoid the case where the mask is just "False"
Expand Down

0 comments on commit cb521f2

Please sign in to comment.