Last active
January 22, 2021 22:05
-
-
Save mlubej/ed8eab964a222dfb42bf72b3235d8915 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
from sentinelhub import CRS | |
# rescale to a lower resolution | |
nres = 120*10 | |
target_crs = CRS.WGS84.epsg | |
def create_rgb_per_timestamp(batch_tile_name): | |
subprocess.run(f'gdalwarp -tr {nres} {nres} <INPUT HI-RES RED> <OUTPUT LO_RES RED>', shell=True) | |
# repeat for green and blue ... | |
for idx, date in enumerate(dates): | |
subprocess.run(f'gdal_translate -b {idx+1} <INPUT LO_RES RED> <OUTPUT LO_RES RED>_{idx}.tif', shell=True) | |
# repeat for green and blue ... | |
# merge separate bands into a multi-channel tiff and reproject to a common crs | |
subprocess.run(f'gdal_merge.py -separate -o <OUTPUT LO_RES RGB>_{idx}.tif -co PHOTOMETRIC=MINISBLACK <OUTPUT LO_RES RED>_{idx}.tif <OUTPUT LO_RES GREEN>_{idx}.tif <OUTPUT LO_RES BLUE>_{idx}.tif', shell=True) | |
subprocess.run(f'gdalwarp -t_srs EPSG:{target_crs} <OUTPUT REPROJECTED RGB>_{idx}.tif <OUTPUT LO_RES RGB>_{idx}.tif', shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment