6

Using this command (DOS window in Win7):

gdal_translate name.tif -of AAIGrid name.asc

Each conversion creates the desired name.asc file, but in addition a name.prj and a name.asc.aux.xml which I do not need. Eventually I have over 20000 of these extra files, all with identical content.

Q: Is there a switch that turns off the creation of these two auxiliary help files?

Version:

gdal_translate --long-usage gives (scrapping latter part):

Usage: gdal_translate [--help-general] [--long-usage]
       [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
             CInt16/CInt32/CFloat32/CFloat64}] [-strict]
       [-of format] [-b band] [-mask band] [-expand {gray|rgb|rgba}]
       [-outsize xsize[%]|0 ysize[%]|0] [-tr xres yres]
       [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]
       [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* [-exponent[_bn] exp_val]*
       [-srcwin xoff yoff xsize ysize] [-epo] [-eco]
       [-projwin ulx uly lrx lry] [-projwin_srs srs_def]
       [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value]
       [-gcp pixel line easting northing [elevation]]*
       [-mo "META-TAG=VALUE"]* [-q] [-sds]
       [-co "NAME=VALUE"]* [-stats] [-norat]
       [-oo NAME=VALUE]*
       src_dataset dst_dataset

GDAL 2.1.2, released 2016/10/24

Have googled, but it's hard to find that one correct hit.

6

I do not believe that you can avoid creating additional files with AAIGrid output. AAIGRid format does not have native internal support for projections and other metadata that GDAL needs in order to make a round trip and convert from AAIGrid back to the original format.

I would call gdal_translate from a script/batch file. For Windows write a batch file "convert.bat"

gdal_translate %1.tif -of AAIGrid %1.asc
del %1.asc.aux.xml
del %1.prj

Then call the batch file as

convert.bat name

EDIT You can disable the creation of aux.xml file by setting the GDAL configuration option GDAL_PAM_ENABLED into "NO". Read https://trac.osgeo.org/gdal/wiki/ConfigOptions#GDAL_PAM_ENABLED.

You can set the option either as an environmental variable

set GDAL_PAM_ENABLED=NO

or in the gdal_translate command by adding

--config GDAL_PAM_ENABLED NO

There may a workaround for disabling .prj as well but I have not discovered it yet.

  • Sounds fair, roundtrip is a good argument for the current behaviour. Not a big job to delete, i'm just the fanatic optimizer. And as i got this rare opportunity, i have to now say thanks Batman! :-) – Stormwind Dec 31 '16 at 12:06
  • Thanks for the addition, works! The --config [ ] is convenient and spares from the defragmentation/alloc space caused by almost 10000 files (and likely 10x more in the end)! – Stormwind Dec 31 '16 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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