Opened 17 years ago
Closed 17 years ago
#1898 closed enhancement (wontfix)
Have an alternative to file pattern matching (gdal_merge)
Reported by: | mcr | Owned by: | warmerdam |
---|---|---|---|
Priority: | low | Milestone: | 1.5.0 |
Component: | default | Version: | 1.4.2 |
Severity: | normal | Keywords: | gdal_merge.py file pattern command line buffer |
Cc: |
Description
If you use wild cards with gdal_merge.py and you have many files to merge the result is "argument line to long" and you have to split your input in smaller portions and then recombine the results.
For example
gdal_merge.py -o out.tif *.tif
may result in this error. A quick fix for me was to introduce a tile file starting with special character @. A File starting with this character consists of Input Data Sources, one per line.
The changes to gdal_merge.py were to insert
import os def getTileList(filename):
""" returns list of tiles, expanding files starting with @ """ inputTiles=[] if os.path.basename(filename)[:1] == '@':
tilefile = open(filename,'r') for fn in tilefile:
inputTiles.append(fn.strip())
del tilefile
else:
inputTiles.append(filename)
return inputTiles
and change the main section from
else:
names.append(arg)
to
else:
fileNames = getTileList(arg); for n in fileNames:
names.append( n )
In my opinion, this should also work for other utilities, gdalwarp for example, otherwise you are always restricted to the size of the command line buffer
Mueller,
The gdal_merge.py script already supports the --optfile switch also supported by most other gdal and ogr tools for supplying a file with additional commandline arguments. So you should be able to create a file named "file.list" and then do a command like:
So, I think this special @ syntax is not strictly necessary.
Thanks,