title: Resampling a raster (python / gdal) with a custom resampling method
body: <p>I am currently experimenting with an (inherited) python script, where we resample a raster (DEM) from 0.5 m to 10 m with the following command:</p>
  <pre><code>os.system(&quot;gdalwarp -tr 10 10 -r max -co COMPRESS=LZW &quot; + vhm_detail + &quot; &quot; + vhm_10m)
  </code></pre>
  <p>basically calling gdalwarp.
  Now I'd like to use a complex custom resampling method (<em>something like &quot;if 33% of pixels are in a class of maximum, use that, otherwise check for majority in another class, otherwise ...&quot; // bottomline: It's complex</em>). In the <a href="https://gdal.org/programs/gdalwarp.html" rel="nofollow noreferrer">gdalwarp doc</a> I found nothing about using a custom resampling method, so I guess I'll have to write my own python code.</p>
  <p><strong>Is it possible to use the gdal-bindings to still use gdalwarp (with a python interface and a custom python function, e.g. in code below <code>_____???_____</code>) or do I have to do this in python altogether?</strong></p>
  <pre><code>from osgeo import gdal
  vhm_10m = gdal.Translate('', 'sample.tif', xres=10, yres=10, resampleAlg=_____???_____)
  </code></pre>
  <p>I haven't worked in Python for a long time, so I'm a bit lost as where to start with this.</p>