#!/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 1641.1438328567801 5442.256905533483 25.14327407 57.17833415 -gcp 18442.340454211735 5632.22850605675 25.14786065 57.11116164 -gcp 18462.1070041577 20302.703610980163 25.0415647 57.10669877 -gcp 1349.8802957795458 19292.868783520702 25.0398159 57.17670297 GX10514/GX_10514_SK_frame_435.jpg GX_10514_SK_frame_435.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "528.0 3767.938303341902\n20016.0 3240.1850899742935\n20088.0 20712.629305912596\n720.0 20688.950128534703" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_435.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_435.vrt GX_10514_SK_frame_435.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_435.cut.vrt GX_10514_SK_frame_435.xyz