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: pyrasterframes/src/main/python/docs/nodata-handling.pymd
+25-17Lines changed: 25 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -148,7 +148,7 @@ display(sample[1])
148
148
149
149
## NoData and Local Arithmatic
150
150
151
-
Let's now explore how the presence of NoData affects local arithmatic operations. To demonstrate the behaviour, lets create two tiles. One tile will have values of 0 and 1, and the other will have values of just 0.
151
+
Let's now explore how the presence of NoData affects @ref:[local map algebra](local-algebra.md) operations. To demonstrate the behaviour, lets create two tiles. One tile will have values of 0 and 1, and the other will have values of just 0.
152
152
153
153
154
154
```python
@@ -161,27 +161,34 @@ y = Tile(np.zeros((tile_size, tile_size), dtype='int16'))
161
161
rf = spark.createDataFrame([Row(x=x, y=y)])
162
162
print('x')
163
163
display(x)
164
+
```
165
+
166
+
```python
164
167
print('y')
165
168
display(y)
166
169
```
167
170
168
-
Now, let's create a new column from `x` with the value of 1 changed to NoData. Then, we will add this new column with NoData to the `y` column. As shown below, the result of the sum also has NoData (represented in white). In general for arithmatic operations, Data + NoData = NoData. To see more information about possible operations on Tile columns, see the @ref:[local map algebra](local-algebra.md) doc.
171
+
Now, let's create a new column from `x` with the value of 1 changed to NoData. Then, we will add this new column with NoData to the `y` column. As shown below, the result of the sum also has NoData (represented in white). In general for local algebra operations, Data + NoData = NoData.
To see more information about possible operations on Tile columns, see the @ref:[local map algebra](local-algebra.md) page and @ref:[function reference](reference.md#local-map-algebra).
179
186
180
187
## Changing a Tile's NoData Values
181
188
182
-
One way to mask a tile is to make a new tile with a user defined NoData value. We will explore this method below. First, lets create a rasterframe from a tile with values of 0, 1, 2, and 3. We will use numpy to create a 100x100 Tile with columns of 0, 1, 2, and 3.
189
+
One way to mask a tile is to make a new tile with a user defined NoData value. We will explore this method below. First, lets create a DataFrame from a tile with values of 0, 1, 2, and 3. We will use numpy to create a 100x100 Tile with vertical bands containing values 0, 1, 2, and 3.
183
190
184
-
```python create_dummy_tile
191
+
```python create_dummy_tile, caption='Dummy Tile'
185
192
tile_size = 100
186
193
x = np.zeros((tile_size, tile_size), dtype='int16')
RasterFrames supports having Tile columns with multiple cell types in a single RasterFrame. It is important to understand how these different cell types interact.
235
+
RasterFrames supports having Tile columns with multiple cell types in a single DataFrame. It is important to understand how these different cell types interact.
229
236
230
237
Let's first create a RasterFrame that has columns of `float` and `int` cell type.
231
238
@@ -234,24 +241,25 @@ x = Tile((np.ones((100, 100))*2).astype('float'))
234
241
y = Tile((np.ones((100, 100))*3.0).astype('int32'))
When performing a local operation between tile columns with cell types `int` and type `float`, the resulting tile cell type will be `float`. If two tiles of different sized integer cell types are added together in the same way, the resulting cell type will be the same as the largest of the two integer cell types.
247
+
When performing a local operation between tile columns with cell types `int` and type `float`, the resulting tile cell type will be `float`. In local algebra over two tiles of different "sized" cell types, the resulting cell type will be the largest of the two input tiles' cell types.
Combining tile columns of different cell types gets a little trickier when user defined NoData cell types are involved. Let's create 2 tile columns: one with a NoData value of 1, and one with a NoData value of 2.
Let's try adding the tile columns with different NoData values. When there is an inconsistent NoData value in the two columns, the NoData value of the right-hand side of the sum is kept. In this case, this means the result has a NoData value of 1.
0 commit comments