locationtech / rasterframes

Geospatial Raster support for Spark DataFrames
http://rasterframes.io
Apache License 2.0
240 stars 46 forks source link

rf_resample parameters #608

Open arind123 opened 1 year ago

arind123 commented 1 year ago

I have rasterframes version 0.11.1. When I try to use the rf_resample function: df.select(rf_resample("proj_raster.tile", 0.25, "max")), I get the following error: rf_resample() takes 2 positional arguments but 3 were given This function is supposed to take three inputs right? Or am I missing something?

pomadchin commented 1 year ago

I guess it is a python question, then yes, it is two args function, see https://github.com/locationtech/rasterframes/blob/0.11.1/python/pyrasterframes/rasterfunctions.py#L1009-L1014:

def rf_resample(tile_col: Column_type, scale_factor: Union[int, float, Column_type]) -> Column:
    """Resample tile to different size based on scalar factor or tile whose dimension to match
    Scalar less than one will downsample tile; greater than one will upsample. Uses nearest-neighbor."""
    if isinstance(scale_factor, (int, float)):
        scale_factor = lit(scale_factor)
    return _apply_column_function("rf_resample", tile_col, scale_factor)
pomadchin commented 1 year ago

Definitely feels like it's never been exposed. You can try using Spark CQL though.

arind123 commented 1 year ago

So to upsampling or dowsampling is not possible using "average" in pyspark? .. I was trying to convert a 10mt band of sentinel 2 to 20mt using this??