#!/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 2818.034905999011 5665.9665603174135 25.42786181 57.17301563 -gcp 18221.792677172423 5982.383691113813 25.43100536 57.11227739 -gcp 18510.64997327955 18453.053354911222 25.34173608 57.1083884 -gcp 3548.3180913180786 19915.34650493881 25.32436609 57.16765295 GX10514/GX_10514_SK_frame_440.jpg GX_10514_SK_frame_440.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1344.0 4041.0\n20832.0 3888.6169665809757\n20880.0 20592.22210796915\n1296.0 20688.27146529563" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_440.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_440.vrt GX_10514_SK_frame_440.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_440.cut.vrt GX_10514_SK_frame_440.xyz