#!/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 26.1955905 56.35405251 -gcp 21885.0 0.0 26.15216494 56.34039388 -gcp 21885.0 21315.0 26.12560408 56.36440696 -gcp 0.0 21315.0 26.17122531 56.3791178 GX704/GX_704_SD_frame_44.jpg GX_704_SD_frame_44.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "936.0 2111.9064066852366\n2376.0 2136.4011142061277\n2472.0 719.585515320334\n18576.0 815.1844011142064\n18624.0 2352.4011142061277\n21048.0 2447.745961002785\n20928.0 20808.1069637883\n2640.0 20832.320891364903\n2088.0 19319.61225626741\n576.0 19175.826183844012" | \ gdaltransform -tps -output_xy GX_704_SD_frame_44.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_704_SD_frame_44.vrt GX_704_SD_frame_44.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_704_SD_frame_44.cut.vrt GX_704_SD_frame_44.xyz