#!/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.67719389 57.39812544 -gcp 10200.0 0.0 25.68735896 57.31114555 -gcp 10200.0 10449.0 25.52705916 57.30466216 -gcp 0.0 10449.0 25.51401501 57.39223199 GX8473/GX_8473_SK_frame_207.jpg GX_8473_SK_frame_207.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1248.0 798.5454711914062\n1236.0001831054688 1516.36376953125\n696.5454711914062 1527.2730102539062\n645.2726440429688 3246.0001831054688\n451.63623046875 3902.181884765625\n462.5455627441406 9626.181518554688\n947.4545288085938 9613.090942382812\n1364.7273559570312 9895.63623046875\n1364.1820678710938 10446.0\n9187.091674804688 10446.0\n9180.544921875 10038.545654296875\n9453.2724609375 9730.36376953125\n10068.0 9705.2724609375\n10042.909423828125 711.2727355957031" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_207.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_207.vrt GX_8473_SK_frame_207.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_207.cut.vrt GX_8473_SK_frame_207.xyz