4

I have a DEM (.asc) file with a resolution of 1000 meters per pixel. Therefore the file has a lot of columns and rows. I would like to chance the resolution per pixel from 1000 to 3000 meters per pixel. So i would like to resample it.

which gdal command do i use for this? i know it's gdalwarp but how is the exact command line with the extra options?

if you know how to do it in QGIS I'm also happy with it.

1 Answer 1

4

The task could feel trivial by reading the gdalwarp documentation http://www.gdal.org/gdalwarp.html and GDAL AAIGrid -- Arc/Info ASCII Grid driver documentation http://www.gdal.org/frmt_various.html. The target pixel size is three times bigger than the native resolution 0.008333333333 degrees/pixel (not 1000 m/pixel, see the comments).

gdalwarp -of AAIGrid -tr 0.024999 0.024999 input.asc output.asc

However, it is a bit more difficult than that.

  • gdalwarp does not support AAIGrid format as direct output format
  • The default resampling method of gdalwarp is nearest neighbor which does not suit well for DEM

Therefore the conversion must be done in two steps and with a better resampling method.

First step is to create an interim output as GDAL Virtual raster (.VRT) with "average" resampling

gdalwarp -of VRT -r average -tr 0.024999 0.024999 input.asc interim.vrt

Second step is to convert the interim DEM into new ASCII Grid file with gdal_translate

gdal_translate -of AAIGrid interim.vrt output.asc

Note:

The formats which are supported for output can be listed with gdalwarp --formats command. Formats which support direct output are marked with "+" character. However, all of them will not really work (NTv2 Datum Grid Shift file for example).

On Windows

gdalwarp --formats|find "+"
  FITS -raster- (rw+): Flexible Image Transport System
  HDF4Image -raster- (rw+): HDF4 Dataset
  netCDF -raster- (rw+s): Network Common Data Format
  VRT -raster- (rw+v): Virtual Raster
  GTiff -raster- (rw+vs): GeoTIFF
  NITF -raster- (rw+vs): National Imagery Transmission Format
  HFA -raster- (rw+v): Erdas Imagine Images (.img)
  ELAS -raster- (rw+v): ELAS
  MEM -raster- (rw+): In Memory Raster
  BMP -raster- (rw+v): MS Windows Device Independent Bitmap
  PCIDSK -raster,vector- (rw+v): PCIDSK Database File
  ILWIS -raster- (rw+v): ILWIS Raster Map
  SGI -raster- (rw+): SGI Image File Format 1.0
  Leveller -raster- (rw+): Leveller heightfield
  Terragen -raster- (rw+): Terragen heightfield
  ISIS2 -raster- (rw+v): USGS Astrogeology ISIS cube (Version 2)
  ERS -raster- (rw+v): ERMapper .ers Labelled
  RMF -raster- (rw+v): Raster Matrix Format
  RST -raster- (rw+v): Idrisi Raster A.1
  INGR -raster- (rw+v): Intergraph Raster
  GSBG -raster- (rw+v): Golden Software Binary Grid (.grd)
  GS7BG -raster- (rw+v): Golden Software 7 Binary Grid (.grd)
  PNM -raster- (rw+v): Portable Pixmap Format (netpbm)
  ENVI -raster- (rw+v): ENVI .hdr Labelled
  EHdr -raster- (rw+v): ESRI .hdr Labelled
  PAux -raster- (rw+): PCI .aux Labelled
  MFF -raster- (rw+): Vexcel MFF Raster
  MFF2 -raster- (rw+): Vexcel MFF2 (HKV) Raster
  BT -raster- (rw+v): VTP .bt (Binary Terrain) 1.3 Format
  LAN -raster- (rw+v): Erdas .LAN/.GIS
  IDA -raster- (rw+v): Image Data and Analysis
  GTX -raster- (rw+v): NOAA Vertical Datum .GTX
  NTv2 -raster- (rw+vs): NTv2 Datum Grid Shift
  CTable2 -raster- (rw+v): CTable2 Datum Grid Shift
  KRO -raster- (rw+v): KOLOR Raw
  ADRG -raster- (rw+vs): ARC Digitized Raster Graphics
  SAGA -raster- (rw+v): SAGA GIS Binary Grid (.sdat)
  PDF -raster,vector- (rw+vs): Geospatial PDF
12
  • 1
    Be sure to use -r average, otherwise the downsampling will pick the middle pixel and ignore the other 8.
    – Mike T
    Commented Oct 30, 2014 at 10:39
  • That's right and sooner or later you just must read the documentation, try to understand it and make your own experiments with demo data instead of trusting on the inaccurate answers we give to you.
    – user30184
    Commented Oct 30, 2014 at 10:46
  • Thanks for the comments. but it appears "Output driver "AAIGrid" not recognised or does not support direct output file creation." Any solution?
    – Duddel
    Commented Oct 30, 2014 at 10:53
  • 1
    It looks like it is compiled by default gdal.org/formats_list.html so then it is the other alternative, not supported as direct output. Try then with -of GTiff and convert geotiff into asc later with gdal_translate. I will edit my answer it that works.
    – user30184
    Commented Oct 30, 2014 at 10:59
  • You can find a list of direct output formats here: gis.stackexchange.com/questions/101387/…
    – AndreJ
    Commented Oct 30, 2014 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.