#!/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 4419.418056026008 4559.776552248831 25.62514365 57.16767293 -gcp 16633.30338811262 5846.852439913013 25.63728333 57.21453703 -gcp 19307.51510884612 18307.48344279036 25.72737873 57.2237557 -gcp 4750.51502861952 18953.394644677213 25.72995901 57.16635589 GX10802/GX_10802_SK_frame_389.jpg GX_10802_SK_frame_389.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "336.0 2331.0\n21072.0 1920.1203342618387\n20832.0 19032.053481894152\n648.0 19344.427855153204" | \ gdaltransform -tps -output_xy GX_10802_SK_frame_389.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10802_SK_frame_389.vrt GX_10802_SK_frame_389.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10802_SK_frame_389.cut.vrt GX_10802_SK_frame_389.xyz