#!/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 2082.3540152864375 5510.416640734283 25.25975704 57.17581902 -gcp 17950.729275832582 6449.957919935445 25.25704801 57.11270537 -gcp 19551.693644398867 17704.614259134338 25.17646909 57.10426289 -gcp 3153.34418737161 18880.082922329297 25.16160429 57.16978753 GX10514/GX_10514_SK_frame_437.jpg GX_10514_SK_frame_437.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "960.0 3863.950642673522\n20736.0 3024.25912596401\n20688.0 20712.22210796915\n1128.0 20688.82673521851" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_437.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_437.vrt GX_10514_SK_frame_437.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_437.cut.vrt GX_10514_SK_frame_437.xyz