Advertisement
Abhisek92

build_vrt.py

Sep 12th, 2021
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import os
  2. from pathlib import Path
  3.  
  4. dst_dir = Path('path')
  5.  
  6. os.chdir(dst_dir)
  7. tiles_dir =  dst_dir / 'Tiles'
  8.  
  9. tiles = list()
  10. for fp in tqdm(list(tiles_dir.glob("*.tif"))):
  11.     tiles.append(str(fp.relative_to(dst_dir)))
  12. vrt_path = dst_dir / "Mosaic_HS.VRT"
  13. vrt_options = gdal.BuildVRTOptions(resampleAlg='near', addAlpha=False)
  14. ds = gdal.BuildVRT(
  15.     str(vrt_path.relative_to(dst_dir)), tiles, options=vrt_options
  16.   )
  17. ds.FlushCache()
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement