#!/bin/bash GDAL_TILE_PROCESSES=16 GDAL_TILE_ZOOMS=8-14 GDAL_SAMPLING_WARP=cubic GDAL_SAMPLING_TILE=antialias # Create virtual dataset with coordinates gdal_translate -of VRT -a_srs EPSG:4326 -outsize 300% 300% -gcp 0.0 0.0 23.16556334 56.73870316 -gcp 21369.0 0.0 23.12674114 56.72510395 -gcp 21369.0 20994.0 23.10029456 56.74678337 -gcp 0.0 20994.0 23.14139664 56.76083932 GX2685/GX_2685B_SD_frame_257.jpg GX_2685B_SD_frame_257.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2256.0 576.0802228412258\n20928.0 623.7593314763226\n21120.0 20688.026740947073\n2208.0 20447.8930362117" | \ gdaltransform -tps -output_xy GX_2685B_SD_frame_257.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2685B_SD_frame_257.vrt GX_2685B_SD_frame_257.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2685B_SD_frame_257.cut.vrt GX_2685B_SD_frame_257.xyz