Resampling Arc Info ASCII Grid file via CLI

Some days ago, I had problems resampling arc info ascii grid file via CLI. Why CLI and not a GIS like GRASS? Because, the engine of every GIS is the GDAL library. Using it via command line is very very fast…once learnt how to do!

gdal resampling arc info ascii grid

Googling, I found the solution in a recent discussion in Here I would like to summarize some important notions, because I need to write everything I want to remember, at least once.

Thus the command gdalwarp is what I need.

gdalwarp -of AAIGrid -tr 0.01 0.01 -r average srcfile.asc dstfile.asc


  • -of format: is the output format;
  • -tr xres yres: set the output file resolution (in target georeferenced units, in my case degrees/pixel for EPSG 4326);
  • -r resampling_method: set the resampling method to use. Available methods are:
    • near:
      nearest neighbour resampling (default, fastest algorithm, worst interpolation quality)
    • bilinear:
      bilinear resampling
    • cubic:
      cubic resampling
    • cubicspline:
      cubic spline resampling
    • lanczos:
      Lanczos windowed sinc resampling
    • average:
      average resampling, computes the average of all non-NODATA contributing pixels
    • mode:
      mode resampling, selects the value which appears most often of all the sampled points.

However, this command return this error:

because gdalwarp does not support AAIGrid format as direct output format.

So, the resampling has to be done with a different file format as output, e.g. the GDAL Virtual raster (.VRT):

gdalwarp -of VRT -tr 0.01 0.01 -r average srcfile.asc dstfile.vrt

done that, it’s possible to conver the DEM into new ASCII Grid file with gdal_translate

gdal_translate -of AAIGrid srcfile.vrt dstfile.asc

About Francesco Serafin

I am a PhD student at the Department of Civil, Environmental and Mechanical Engineering at the University of Trento. My two greatest loves: Computer Science and Water (take three with my Lenovo!:D). As a result, the aim of my life is to make both passions coexist. My gpg public key available at

3 thoughts on “Resampling Arc Info ASCII Grid file via CLI

  1. Thanks for your personal marvelous posting! I certainly enjoyed reading
    it, you’re a great author.I will be sure to bookmark your blog and will come back later in life.

    I want to encourage you continue your great work,
    have a nice day!

Leave a Reply

Your email address will not be published.