Skip to content

Commit 8d223ad

Browse files
committed
Close #228 and #331 with discussion on writing page; clean up unsupervised learning output.
Signed-off-by: Jason T. Brown <[email protected]>
1 parent a659756 commit 8d223ad

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

pyrasterframes/src/main/python/docs/raster-write.pymd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ If there are many _tile_ or projected raster columns in the DataFrame, the GeoTI
129129
os.remove(outfile)
130130
```
131131

132+
### Downsampling
133+
134+
If no `raster_dimensions` column is specified the DataFrame contents are written at full resolution. As shown in the example above, you can also specify the size of the output GeoTIFF. Bilinear resampling is used.
135+
136+
137+
### Color Composites
138+
139+
If the DataFrame has three or four tile columns, the GeoTIFF is written with the `ColorInterp` tags on the [bands](https://gdal.org/user/raster_data_model.html?highlight=color%20interpretation#raster-band) to indicate red, green, blue, and optionally alpha. Use a `select` statement to ensure your intended color compositing. Note that any other number of tile columns will result in a greyscale interpretation.
140+
141+
132142
## Overview Rasters
133143

134144
In cases where writing and reading to/from a GeoTIFF isn't convenient, RasterFrames provides the @ref:[`rf_agg_overview_raster`](reference.md#rf-agg-overview-raster) aggregate function, where you can construct a single raster (rendered as a tile) downsampled from all or a subset of the DataFrame. This allows you to effectively construct the same operations the GeoTIFF writer performs, but without the file I/O.

pyrasterframes/src/main/python/docs/unsupervised-learning.pymd

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,20 +118,23 @@ retiled = clustered.groupBy('extent', 'crs') \
118118
rf_assemble_tile('column_index', 'row_index', 'prediction',
119119
tile_dims['cols'], tile_dims['rows'], CellType.int8()).alias('prediction')
120120
)
121-
122-
retiled.printSchema()
123-
```
124-
125-
```python, display
126-
retiled
127121
```
128122

129123
The resulting output is shown below.
130124

131125
```python, viz
132-
133-
# display(retiled.select('prediction').first()['prediction'])
134126
from pyrasterframes.rf_types import Extent
135-
aoi = Extent.from_row(retiled.select(rf_agg_extent('extent')).first()[0])
136-
retiled.select(rf_agg_overview_raster('prediction', 186, 169, aoi, 'extent', 'crs'))
127+
aoi = Extent.from_row(
128+
retiled.agg(rf_agg_reprojected_extent('extent', 'crs', 'epsg:3857')) \
129+
.first()[0]
130+
)
131+
132+
retiled.select(rf_agg_overview_raster('prediction', 558, 507, aoi, 'extent', 'crs'))
137133
```
134+
135+
136+
```python, viz-true-color, evaluate=False, echo=False
137+
#For comparison, the true color composite of the original data.
138+
# this is really dark
139+
df.select(rf_render_png('b4', 'b3', 'b2'))
140+
```

0 commit comments

Comments
 (0)