Skip to content

Commit 1b8a3a8

Browse files
committed
add an option to pass tiff list to tile tool
1 parent 41c5da5 commit 1b8a3a8

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ tile --tiles-dir <dir> --tiffs-dir <dir> --max-zoom <zoom> --name <name> --descr
226226
```
227227

228228
- `--tiles-dir`: Directory to store the output tiles. (Required)
229-
- `--tiffs-dir`: Directory containing the input GeoTIFF files. (Required)
229+
- `--tiffs-dir`: Directory containing the input GeoTIFF files. (Optional if `--tiffs-list-file` is used)
230+
- `--tiffs-list-file`: File containing a list of tiff files to tile. (Optional if `--tiffs-dir` is used)
230231
- `--max-zoom`: Maximum zoom level for tiling. (Required)
231232
- `--name`: Name of the mosaic. (Required)
232233
- `--description`: Description of the mosaic. (Required)

topo_map_processor/tools/tile.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def cli():
7575

7676
parser = argparse.ArgumentParser(description='Tile the GTiffs and create a TileJSON file')
7777
parser.add_argument('--tiles-dir', required=True, help='Directory to store the tiles')
78-
parser.add_argument('--tiffs-dir', required=True, help='Directory with GTiffs to tile')
78+
tiffs_group = parser.add_mutually_exclusive_group(required=True)
79+
tiffs_group.add_argument('--tiffs-dir', help='Directory with GTiffs to tile')
80+
tiffs_group.add_argument('--tiffs-list-file', help='File containing a list of tiff files to tile')
7981
parser.add_argument('--max-zoom', type=int, required=True, help='Maximum zoom level for tiling')
8082
parser.add_argument('--min-zoom', type=int, default=0, help='Minimum zoom level for tiling')
8183
parser.add_argument('--tile-extension', type=str, default='webp', choices=SUPPORTED_FORMATS, help='Tile file extension (default: webp)')
@@ -102,8 +104,15 @@ def cli():
102104
tiles_dir = Path(args.tiles_dir)
103105
tiles_dir.mkdir(parents=True, exist_ok=True)
104106

105-
file_names = list(glob.glob(f'{args.tiffs_dir}/*.tif'))
106-
file_names = [ str(Path(f).resolve()) for f in file_names ]
107+
if args.tiffs_dir:
108+
file_names = list(glob.glob(f'{args.tiffs_dir}/*.tif'))
109+
file_names = [ str(Path(f).resolve()) for f in file_names ]
110+
else:
111+
tiff_list_path = Path(args.tiffs_list_file)
112+
if not tiff_list_path.exists():
113+
parser.error(f'Tiffs list file {args.tiffs_list_file} does not exist')
114+
file_names = [str(Path(line.strip()).resolve()) for line in tiff_list_path.read_text().splitlines() if line.strip()]
115+
107116
print(f'total files: {len(file_names)}')
108117

109118
file_list_file = Path('files_to_tile.txt')

0 commit comments

Comments
 (0)