Skip to content

Commit 456b4ff

Browse files
committed
Merge branch 'hotfix/0.8.4-b'
2 parents 4b2c72b + dfa1aa4 commit 456b4ff

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pyrasterframes/src/main/python/docs/masking.pymd

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,19 @@ to_clip = to_rasterize.withColumn('clip_raster',
118118
rf_rasterize('geom_native', rf_geometry('blue_masked'), lit(1), rf_dimensions('blue_masked').cols, rf_dimensions('blue_masked').rows))
119119

120120
# visualize some of the edges of our circle
121-
to_clip.select('clip_raster', 'blue_masked') \
121+
to_clip.select('blue_masked', 'clip_raster') \
122122
.filter(rf_data_cells('clip_raster') > 20) \
123123
.orderBy(rf_data_cells('clip_raster'))
124124
```
125125

126126
Finally, we create a new _tile_ column with the blue band clipped to our circle. Again we will use the `rf_mask` function to pass the NoData regions along from the rasterized geometry.
127127

128-
clipped = to_clip.select('blue_masked',
129-
'clip_raster',
130-
rf_mask('blue_masked', 'clip_raster').alias('blue_clipped')) \
131-
.filter(rf_data_cells('clip_raster') > 20) \
132-
.orderBy(rf_data_cells('clip_raster'))
133-
128+
```python, clip
129+
to_clip.select('blue_masked',
130+
'clip_raster',
131+
rf_mask('blue_masked', 'clip_raster').alias('blue_clipped')) \
132+
.filter(rf_data_cells('clip_raster') > 20) \
133+
.orderBy(rf_data_cells('clip_raster'))
134+
```
134135

135136
This kind of clipping technique is further used in @ref:[zonal statistics](zonal-algebra.md).

0 commit comments

Comments
 (0)