You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/core_match_ref.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ at modifying the georeferencing of {class}`Rasters<geoutils.Raster>` or {class}`
62
62
63
63
The {func}`~geoutils.Vector.rasterize` operation to convert from {class}`~geoutils.Vector` to {class}`~geoutils.Raster` accepts a {class}`~geoutils.Raster` to define the
64
64
grid and georeferencing. The behaviour is similar for {func}`~geoutils.Vector.create_mask`, that directly relies on {func}`~geoutils.Vector.rasterize` to
65
-
rasterize directly into a boolean {class}`~geoutils.RasterMask`.
65
+
rasterize directly into a boolean {class}`~geoutils.Raster`.
66
66
67
67
In addition, the {func}`~geoutils.Vector.proximity` operation to compute proximity distances from the vector also relies on a
68
68
{func}`~geoutils.Vector.rasterize`, and therefore also accepts a {class}`~geoutils.Raster` as reference.
Copy file name to clipboardExpand all lines: doc/source/core_py_ops.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,14 +69,13 @@ If an unmasked {class}`~numpy.ndarray` is passed, it will internally be cast int
69
69
{class}`~geoutils.Raster.nodata` values. Additionally, the {attr}`~geoutils.Raster.dtype` are also reconciled as they would for {class}`~numpy.ndarray`,
70
70
following [standard NumPy coercion rules](https://numpy.org/doc/stable/reference/generated/numpy.find_common_type.html).
71
71
72
-
## Logical comparisons cast to {class}`~geoutils.RasterMask`
{func}`<<operator.lt>`) can be used on a {class}`~geoutils.Raster`, also in combination with any other {class}`~geoutils.Raster`, {class}`~numpy.ndarray` or
76
76
number.
77
77
78
-
Those operation always return a {class}`~geoutils.RasterMask`, a subclass of {class}`~geoutils.Raster` with a boolean {class}`~numpy.ma.MaskedArray`
79
-
as {class}`~geoutils.Raster.data`.
78
+
Those operation always return a raster mask i.e. a {class}`~geoutils.Raster` with a boolean {class}`~numpy.ma.MaskedArray` as {class}`~geoutils.Raster.data`.
80
79
81
80
```{code-cell} ipython3
82
81
# Logical comparison with a number
@@ -85,14 +84,14 @@ mask
85
84
```
86
85
87
86
```{note}
88
-
A {class}`~geoutils.RasterMask`'s {attr}`~geoutils.Raster.data` remains a {class}`~numpy.ma.MaskedArray`. Therefore, it still maps invalid values through its
89
-
{attr}`~numpy.ma.MaskedArray.mask`, but has no associated {attr}`~geoutils.Raster.nodata`.
87
+
A boolean {class}`~geoutils.Raster`'s {attr}`~geoutils.Raster.data` remains a {class}`~numpy.ma.MaskedArray`. Therefore, it still maps invalid values
88
+
through its {attr}`~numpy.ma.MaskedArray.mask`, but has no associated {attr}`~geoutils.Raster.nodata`.
90
89
```
91
90
92
-
## Logical bitwise operations on {class}`~geoutils.RasterMask`
91
+
## Logical bitwise operations on raster masks
93
92
94
93
Logical bitwise operators ({func}`~ <operator.invert>`, {func}`& <operator.and_>`, {func}`| <operator.or_>`, {func}`^ <operator.xor>`) can be used to
95
-
combine a {class}`~geoutils.RasterMask` with another {class}`~geoutils.RasterMask`, and always output a {class}`~geoutils.RasterMask`.
94
+
combine a boolean {class}`~geoutils.Raster` with another boolean {class}`~geoutils.Raster`, and always output a boolean {class}`~geoutils.Raster`.
96
95
97
96
```{code-cell} ipython3
98
97
# Logical bitwise operation between masks
@@ -102,17 +101,18 @@ mask
102
101
103
102
(py-ops-indexing)=
104
103
105
-
## Indexing a {class}`~geoutils.Raster` with a {class}`~geoutils.RasterMask`
104
+
## Indexing a {class}`~geoutils.Raster` with a raster mask
106
105
107
106
Finally, indexing and index assignment operations ({func}`[] <operator.getitem>`, {func}`[]= <operator.setitem>`) are both supported by
108
107
{class}`Rasters<geoutils.Raster>`.
109
108
110
-
For indexing, they can be passed either a {class}`~geoutils.RasterMask` with the same georeferencing, or a boolean {class}`~numpy.ndarray` of the same shape.
109
+
For indexing, they can be passed either a boolean {class}`~geoutils.Raster` with the same georeferencing, or a boolean {class}`~numpy.ndarray` of the same
110
+
shape.
111
111
For assignment, either a {class}`~geoutils.Raster` with the same georeferencing, or any {class}`~numpy.ndarray` of the same shape is expected.
112
112
113
-
When indexing, a flattened {class}`~numpy.ma.MaskedArray` is returned with the indexed values of the {class}`~geoutils.RasterMask`**excluding those masked in its
114
-
{class}`~geoutils.Raster.data`'s {class}`~numpy.ma.MaskedArray` (for instance, nodata values present during a previous logical comparison)**. To bypass this
115
-
behaviour, simply index without the mask using {attr}`Mask.data.data`.
113
+
When indexing, a flattened {class}`~numpy.ma.MaskedArray` is returned with the indexed values of the boolean {class}`~geoutils.Raster`**excluding those masked
114
+
in its {class}`~geoutils.Raster.data`'s {class}`~numpy.ma.MaskedArray` (for instance, nodata values present during a previous logical comparison)**. To bypass this
115
+
behaviour, simply index without the mask using {attr}`Raster.data.data`.
Copy file name to clipboardExpand all lines: doc/source/feature_overview.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -195,25 +195,26 @@ import numpy as np
195
195
rast = (rast - np.min(rast)) / (np.max(rast) - np.min(rast))
196
196
```
197
197
198
-
## Casting to {class}`~geoutils.RasterMask`, indexing and overload
198
+
## Casting to raster mask, indexing and overload
199
199
200
200
All {class}`~geoutils.Raster` objects also support Python logical comparison operators ({func}`==<operator.eq>`, {func}` != <operator.ne>`, {func}`>=<operator.ge>`, {func}`><operator.gt>`, {func}`<=<operator.le>`,
201
-
{func}`<<operator.lt>`), or more complex NumPy logical functions. Those operations automatically casts them into a {class}`~geoutils.RasterMask`, a boolean raster that inherits all methods from {class}`~geoutils.Raster`.
201
+
{func}`<<operator.lt>`), or more complex NumPy logical functions. Those operations automatically casts them into a raster mask, i.e. a boolean
202
+
{class}`~geoutils.Raster`.
202
203
203
204
```{code-cell} ipython3
204
205
# Get mask of an AOI: infrared index above 0.6, at least 200 m from glaciers
Masks can then be used for indexing a {class}`~geoutils.Raster`, which returns a {class}`~numpy.ma.MaskedArray` of indexed values.
209
+
Raster masks can then be used for indexing a {class}`~geoutils.Raster`, which returns a {class}`~numpy.ma.MaskedArray` of indexed values.
209
210
210
211
```{code-cell} ipython3
211
212
# Index raster with mask to extract a 1-D array
212
213
values_aoi = rast[mask_aoi]
213
214
```
214
215
215
-
Masks also have simplified, overloaded {class}`~geoutils.Raster` methods due to their boolean {class}`dtype<numpy.dtype>`. Using {func}`~geoutils.Raster.polygonize` with a
216
-
{class}`~geoutils.RasterMask` is straightforward, for instance, to retrieve a {class}`~geoutils.Vector` of the area-of-interest:
216
+
Raster masks also have simplified{class}`~geoutils.Raster` methods due to their boolean {class}`dtype<numpy.dtype>` rendering many arguments implicit.
217
+
For instance, using {func}`~geoutils.Raster.polygonize` with a raster mask is straightforward, to retrieve a {class}`~geoutils.Vector` of the area-of-interest:
0 commit comments