#!/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 25.40224671 57.074662 -gcp 14286.0 0.0 25.56254625 57.07603824 -gcp 14286.0 14706.0 25.56376934 56.98930582 -gcp 0.0 14706.0 25.40738583 56.98720156 GX220/GX_220_SK_frame_579.jpg GX_220_SK_frame_579.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1584.0 311.98662952646237\n12744.0 288.06685236768817\n12768.0 13992.307520891365\n1584.0 14016.227298050138" | \ gdaltransform -tps -output_xy GX_220_SK_frame_579.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_220_SK_frame_579.vrt GX_220_SK_frame_579.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_220_SK_frame_579.cut.vrt GX_220_SK_frame_579.xyz