tazrart
tazrart

Reputation: 167

How to change the resampling method in rasterio's rio.reproject_match function (python)?

I wanted to apply to raster 1 the resolution and origin of raster 2. I found the rasterio's "rio.reproject_match" function. This take the transformation correctly but I couldn't change the default resampling method (nearst). My raster (1) represents land cover, so I wanted to apply the "mode" method. According to the definition here : https://corteva.github.io/rioxarray/html/rioxarray.html#rioxarray.raster_array.RasterArray.reproject_match

I thought of this code:

raster_match = raster_1.rio.reproject_match(raster_2,Resampling = Resampling.mode)

But I found the error below:

NameError: name 'Resampling' is not defined

I wanted to confirm with you if it is possible to change this method directly in rio.reproject_match function and how?

Thanks in advance,

Upvotes: 0

Views: 333

Answers (1)

konse
konse

Reputation: 1075

To be honest, I think there is another problem here: the parameter for reproject_match is called resampling and not Resampling. So it could be that your Resampling.mode is never actually passed into reproject_match! At least this is what happened to me.

So your function call should be

raster_match = raster_1.rio.reproject_match(raster_2,resampling = Resampling.mode)

Upvotes: 0

Related Questions