Process large lists of geospatial files using gdaltindex in parallel batches, then merge results into a single FlatGeoBuf file.
- GDAL tools (
gdaltindex,ogrmerge.py) - Bash 4.0+
- Standard Unix utilities (
xargs,split,find)
Ubuntu/Debian:
sudo apt install gdal-bin python3-gdalFedora:
sudo dnf install gdal gdal-python-toolsmacOS (Homebrew):
brew install gdal./gdaltindex_mp.sh -i INPUT_FILE -o OUTPUT_FILE [OPTIONS]| Argument | Description |
|---|---|
-i, --input FILE |
Text file containing list of geospatial files (one per line) |
-o, --output FILE |
Output FlatGeoBuf file name (e.g., output.fgb) |
| Argument | Description |
|---|---|
-b, --batch-size N |
Number of files per batch (default: 1000) |
-j, --jobs N |
Number of parallel jobs (default: all CPUs) |
-t, --temp-dir DIR |
Directory for temporary files (default: auto-created) |
-k, --keep-temp |
Keep temporary files after completion |
-h, --help |
Show help message |
./gdaltindex_mp.sh -i file_list.txt -o index.fgb./gdaltindex_mp.sh -i file_list.txt -o index.fgb -b 500 -j 8./gdaltindex_mp.sh -i file_list.txt -o index.fgb -k -t /tmp/my_tempThe input file should contain one geospatial file path per line:
/path/to/file1.tif
/path/to/file2.tif
/path/to/file3.tif
Generate a file list with find:
find /data/imagery -name "*.tif" > file_list.txt- Splits the input file list into batches
- Runs
gdaltindexin parallel on each batch, creating intermediate GeoPackage files - Merges all GeoPackages into a single FlatGeoBuf output file
- Cleans up temporary files (unless
-kis specified)