@@ -73,8 +73,8 @@ trait RasterFunctions {
7373
7474 @ Experimental
7575 /** Convert array in `arrayCol` into a Tile of dimensions `cols` and `rows`*/
76- def rf_array_to_tile (arrayCol : Column , cols : Int , rows : Int ) = withAlias (" rf_array_to_tile" , arrayCol )(
77- udf[Tile , AnyRef ](F .arrayToTile(cols, rows)).apply(arrayCol)
76+ def rf_array_to_tile (arrayCol : Column , cols : Int , rows : Int ): TypedColumn [ Any , Tile ] = withTypedAlias (" rf_array_to_tile" )(
77+ udf[Tile , AnyRef ](F .arrayToTile(cols, rows)).apply(arrayCol).as[ Tile ]
7878 )
7979
8080 /** Create a Tile from a column of cell data with location indexes and preform cell conversion. */
@@ -89,12 +89,10 @@ trait RasterFunctions {
8989 def rf_cell_type (col : Column ): TypedColumn [Any , CellType ] = GetCellType (col)
9090
9191 /** Change the Tile's cell type */
92- def rf_convert_cell_type (col : Column , cellType : CellType ): TypedColumn [Any , Tile ] =
93- SetCellType (col, cellType)
92+ def rf_convert_cell_type (col : Column , cellType : CellType ): Column = SetCellType (col, cellType)
9493
9594 /** Change the Tile's cell type */
96- def rf_convert_cell_type (col : Column , cellTypeName : String ): TypedColumn [Any , Tile ] =
97- SetCellType (col, cellTypeName)
95+ def rf_convert_cell_type (col : Column , cellTypeName : String ): Column = SetCellType (col, cellTypeName)
9896
9997 /** Resample tile to different size based on scalar factor or tile whose dimension to match. Scalar less
10098 * than one will downsample tile; greater than one will upsample. Uses nearest-neighbor. */
@@ -110,18 +108,20 @@ trait RasterFunctions {
110108 /** Extract the extent of a RasterSource or ProjectedRasterTile as a Geometry type. */
111109 def rf_geometry (raster : Column ): TypedColumn [Any , Geometry ] = GetGeometry (raster)
112110
113- /** Assign a `NoData` value to the Tiles. */
114- def rf_with_no_data (col : Column , nodata : Double ): TypedColumn [Any , Tile ] = withTypedAlias(" rf_with_no_data" , col)(
115- udf[Tile , Tile ](F .withNoData(nodata)).apply(col)
116- )
111+ /** Assign a `NoData` value to the tile column. */
112+ def rf_with_no_data (col : Column , nodata : Double ): Column = SetNoDataValue (col, nodata)
113+
114+ /** Assign a `NoData` value to the tile column. */
115+ def rf_with_no_data (col : Column , nodata : Int ): Column = SetNoDataValue (col, nodata)
116+
117+ /** Assign a `NoData` value to the tile column. */
118+ def rf_with_no_data (col : Column , nodata : Column ): Column = SetNoDataValue (col, nodata)
117119
118120 /** Compute the full column aggregate floating point histogram. */
119- def rf_agg_approx_histogram (col : Column ): TypedColumn [Any , CellHistogram ] =
120- HistogramAggregate (col)
121+ def rf_agg_approx_histogram (col : Column ): TypedColumn [Any , CellHistogram ] = HistogramAggregate (col)
121122
122123 /** Compute the full column aggregate floating point statistics. */
123- def rf_agg_stats (col : Column ): TypedColumn [Any , CellStatistics ] =
124- CellStatsAggregate (col)
124+ def rf_agg_stats (col : Column ): TypedColumn [Any , CellStatistics ] = CellStatsAggregate (col)
125125
126126 /** Computes the column aggregate mean. */
127127 def rf_agg_mean (col : Column ) = CellMeanAggregate (col)
@@ -194,28 +194,28 @@ trait RasterFunctions {
194194 def rf_agg_local_no_data_cells (col : Column ): TypedColumn [Any , Tile ] = LocalCountAggregate .LocalNoDataCellsUDAF (col)
195195
196196 /** Cellwise addition between two Tiles or Tile and scalar column. */
197- def rf_local_add (left : Column , right : Column ): TypedColumn [ Any , Tile ] = Add (left, right)
197+ def rf_local_add (left : Column , right : Column ): Column = Add (left, right)
198198
199199 /** Cellwise addition of a scalar value to a tile. */
200- def rf_local_add [T : Numeric ](tileCol : Column , value : T ): TypedColumn [ Any , Tile ] = Add (tileCol, value)
200+ def rf_local_add [T : Numeric ](tileCol : Column , value : T ): Column = Add (tileCol, value)
201201
202202 /** Cellwise subtraction between two Tiles. */
203- def rf_local_subtract (left : Column , right : Column ): TypedColumn [ Any , Tile ] = Subtract (left, right)
203+ def rf_local_subtract (left : Column , right : Column ): Column = Subtract (left, right)
204204
205205 /** Cellwise subtraction of a scalar value from a tile. */
206- def rf_local_subtract [T : Numeric ](tileCol : Column , value : T ): TypedColumn [ Any , Tile ] = Subtract (tileCol, value)
206+ def rf_local_subtract [T : Numeric ](tileCol : Column , value : T ): Column = Subtract (tileCol, value)
207207
208208 /** Cellwise multiplication between two Tiles. */
209- def rf_local_multiply (left : Column , right : Column ): TypedColumn [ Any , Tile ] = Multiply (left, right)
209+ def rf_local_multiply (left : Column , right : Column ): Column = Multiply (left, right)
210210
211211 /** Cellwise multiplication of a tile by a scalar value. */
212- def rf_local_multiply [T : Numeric ](tileCol : Column , value : T ): TypedColumn [ Any , Tile ] = Multiply (tileCol, value)
212+ def rf_local_multiply [T : Numeric ](tileCol : Column , value : T ): Column = Multiply (tileCol, value)
213213
214214 /** Cellwise division between two Tiles. */
215- def rf_local_divide (left : Column , right : Column ): TypedColumn [ Any , Tile ] = Divide (left, right)
215+ def rf_local_divide (left : Column , right : Column ): Column = Divide (left, right)
216216
217217 /** Cellwise division of a tile by a scalar value. */
218- def rf_local_divide [T : Numeric ](tileCol : Column , value : T ): TypedColumn [ Any , Tile ] = Divide (tileCol, value)
218+ def rf_local_divide [T : Numeric ](tileCol : Column , value : T ): Column = Divide (tileCol, value)
219219
220220 /** Perform an arbitrary GeoTrellis `LocalTileBinaryOp` between two Tile columns. */
221221 def rf_local_algebra (op : LocalTileBinaryOp , left : Column , right : Column ): TypedColumn [Any , Tile ] =
@@ -231,9 +231,8 @@ trait RasterFunctions {
231231
232232 /** Constructor for tile column with a single cell value. */
233233 def rf_make_constant_tile (value : Number , cols : Int , rows : Int , cellTypeName : String ): TypedColumn [Any , Tile ] = {
234- import org .apache .spark .sql .rf .TileUDT .tileSerializer
235- val constTile = encoders.serialized_literal(F .makeConstantTile(value, cols, rows, cellTypeName))
236- withTypedAlias(s " rf_make_constant_tile( $value, $cols, $rows, $cellTypeName) " )(constTile)
234+ val constTile = udf(() => F .makeConstantTile(value, cols, rows, cellTypeName))
235+ withTypedAlias(s " rf_make_constant_tile( $value, $cols, $rows, $cellTypeName) " )(constTile.apply())
237236 }
238237
239238 /** Create a column constant tiles of zero */
@@ -326,96 +325,72 @@ trait RasterFunctions {
326325 DebugRender .RenderMatrix (col)
327326
328327 /** Cellwise less than value comparison between two tiles. */
329- def rf_local_less (left : Column , right : Column ): TypedColumn [Any , Tile ] =
330- Less (left, right)
328+ def rf_local_less (left : Column , right : Column ): Column = Less (left, right)
331329
332330 /** Cellwise less than value comparison between a tile and a scalar. */
333- def rf_local_less [T : Numeric ](tileCol : Column , value : T ): TypedColumn [Any , Tile ] =
334- Less (tileCol, value)
331+ def rf_local_less [T : Numeric ](tileCol : Column , value : T ): Column = Less (tileCol, value)
335332
336333 /** Cellwise less than or equal to value comparison between a tile and a scalar. */
337- def rf_local_less_equal (left : Column , right : Column ): TypedColumn [Any , Tile ] =
338- LessEqual (left, right)
334+ def rf_local_less_equal (left : Column , right : Column ): Column = LessEqual (left, right)
339335
340336 /** Cellwise less than or equal to value comparison between a tile and a scalar. */
341- def rf_local_less_equal [T : Numeric ](tileCol : Column , value : T ): TypedColumn [Any , Tile ] =
342- LessEqual (tileCol, value)
337+ def rf_local_less_equal [T : Numeric ](tileCol : Column , value : T ): Column = LessEqual (tileCol, value)
343338
344339 /** Cellwise greater than value comparison between two tiles. */
345- def rf_local_greater (left : Column , right : Column ): TypedColumn [Any , Tile ] =
346- Greater (left, right)
340+ def rf_local_greater (left : Column , right : Column ): Column = Greater (left, right)
347341
348342 /** Cellwise greater than value comparison between a tile and a scalar. */
349- def rf_local_greater [T : Numeric ](tileCol : Column , value : T ): TypedColumn [Any , Tile ] =
350- Greater (tileCol, value)
351-
343+ def rf_local_greater [T : Numeric ](tileCol : Column , value : T ): Column = Greater (tileCol, value)
352344 /** Cellwise greater than or equal to value comparison between two tiles. */
353- def rf_local_greater_equal (left : Column , right : Column ): TypedColumn [Any , Tile ] =
354- GreaterEqual (left, right)
345+ def rf_local_greater_equal (left : Column , right : Column ): Column = GreaterEqual (left, right)
355346
356347 /** Cellwise greater than or equal to value comparison between a tile and a scalar. */
357- def rf_local_greater_equal [T : Numeric ](tileCol : Column , value : T ): TypedColumn [Any , Tile ] =
358- GreaterEqual (tileCol, value)
348+ def rf_local_greater_equal [T : Numeric ](tileCol : Column , value : T ): Column = GreaterEqual (tileCol, value)
359349
360350 /** Cellwise equal to value comparison between two tiles. */
361- def rf_local_equal (left : Column , right : Column ): TypedColumn [Any , Tile ] =
362- Equal (left, right)
351+ def rf_local_equal (left : Column , right : Column ): Column = Equal (left, right)
363352
364353 /** Cellwise equal to value comparison between a tile and a scalar. */
365- def rf_local_equal [T : Numeric ](tileCol : Column , value : T ): TypedColumn [Any , Tile ] =
366- Equal (tileCol, value)
354+ def rf_local_equal [T : Numeric ](tileCol : Column , value : T ): Column = Equal (tileCol, value)
367355
368356 /** Cellwise inequality comparison between two tiles. */
369- def rf_local_unequal (left : Column , right : Column ): TypedColumn [Any , Tile ] =
370- Unequal (left, right)
357+ def rf_local_unequal (left : Column , right : Column ): Column = Unequal (left, right)
371358
372359 /** Cellwise inequality comparison between a tile and a scalar. */
373- def rf_local_unequal [T : Numeric ](tileCol : Column , value : T ): TypedColumn [Any , Tile ] =
374- Unequal (tileCol, value)
360+ def rf_local_unequal [T : Numeric ](tileCol : Column , value : T ): Column = Unequal (tileCol, value)
375361
376362 /** Round cell values to nearest integer without chaning cell type. */
377- def rf_round (tileCol : Column ): TypedColumn [Any , Tile ] =
378- Round (tileCol)
363+ def rf_round (tileCol : Column ): Column = Round (tileCol)
379364
380365 /** Compute the absolute value of each cell. */
381- def rf_abs (tileCol : Column ): TypedColumn [Any , Tile ] =
382- Abs (tileCol)
366+ def rf_abs (tileCol : Column ): Column = Abs (tileCol)
383367
384368 /** Take natural logarithm of cell values. */
385- def rf_log (tileCol : Column ): TypedColumn [Any , Tile ] =
386- Log (tileCol)
369+ def rf_log (tileCol : Column ): Column = Log (tileCol)
387370
388371 /** Take base 10 logarithm of cell values. */
389- def rf_log10 (tileCol : Column ): TypedColumn [Any , Tile ] =
390- Log10 (tileCol)
372+ def rf_log10 (tileCol : Column ): Column = Log10 (tileCol)
391373
392374 /** Take base 2 logarithm of cell values. */
393- def rf_log2 (tileCol : Column ): TypedColumn [Any , Tile ] =
394- Log2 (tileCol)
375+ def rf_log2 (tileCol : Column ): Column = Log2 (tileCol)
395376
396377 /** Natural logarithm of one plus cell values. */
397- def rf_log1p (tileCol : Column ): TypedColumn [Any , Tile ] =
398- Log1p (tileCol)
378+ def rf_log1p (tileCol : Column ): Column = Log1p (tileCol)
399379
400380 /** Exponential of cell values */
401- def rf_exp (tileCol : Column ): TypedColumn [Any , Tile ] =
402- Exp (tileCol)
381+ def rf_exp (tileCol : Column ): Column = Exp (tileCol)
403382
404383 /** Ten to the power of cell values */
405- def rf_exp10 (tileCol : Column ): TypedColumn [Any , Tile ] =
406- Exp10 (tileCol)
384+ def rf_exp10 (tileCol : Column ): Column = Exp10 (tileCol)
407385
408386 /** Two to the power of cell values */
409- def rf_exp2 (tileCol : Column ): TypedColumn [Any , Tile ] =
410- Exp2 (tileCol)
387+ def rf_exp2 (tileCol : Column ): Column = Exp2 (tileCol)
411388
412389 /** Exponential of cell values, less one*/
413- def rf_expm1 (tileCol : Column ): TypedColumn [Any , Tile ] =
414- ExpM1 (tileCol)
390+ def rf_expm1 (tileCol : Column ): Column = ExpM1 (tileCol)
415391
416392 /** Return the incoming tile untouched. */
417- def rf_identity (tileCol : Column ): TypedColumn [Any , Tile ] =
418- Identity (tileCol)
393+ def rf_identity (tileCol : Column ): Column = Identity (tileCol)
419394
420395 /** Create a row for each cell in Tile. */
421396 def rf_explode_tiles (cols : Column * ): Column = rf_explode_tiles_sample(1.0 , None , cols : _* )
0 commit comments