#!/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 1318.5622881894878 4717.166525183283 24.85203981 57.2623248 -gcp 18193.54113525053 3097.6671620620145 24.84266818 57.33010049 -gcp 19950.21214326128 14932.725076164692 24.93106842 57.33594339 -gcp 1263.870867697236 18756.011628989887 24.95749891 57.26103678 GX8464/GX_8464_SK_frame_284.jpg GX_8464_SK_frame_284.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "312.0 2592.0\n480.0 17110.796657381616\n20712.0 17014.71643454039\n20880.0 2327.9866295264624" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_284.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_284.vrt GX_8464_SK_frame_284.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_284.cut.vrt GX_8464_SK_frame_284.xyz