#!/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 1100.5080446085244 7651.000860330618 25.4156363 57.26349723 -gcp 17813.629984832038 4811.6606628434865 25.39442539 57.32975879 -gcp 17683.896917052774 15018.57878618227 25.47002077 57.32878581 -gcp 5328.8700628249935 18550.02483753798 25.49545884 57.28022873 GX8464/GX_8464_SK_frame_275.jpg GX_8464_SK_frame_275.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 2070.0\n20688.0 2208.0534818941505\n20544.0 19103.946518105848\n624.0 18624.748746518108" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_275.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_275.vrt GX_8464_SK_frame_275.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_275.cut.vrt GX_8464_SK_frame_275.xyz