#!/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 4235.012027883924 4453.68143166471 25.32446802 57.16770506 -gcp 19066.433066298065 5842.513815632276 25.31757474 57.10918574 -gcp 18337.445077047865 18837.228421672502 25.22428215 57.10954198 -gcp 3288.3675261916696 18935.757963960747 25.21826327 57.16988932 GX10514/GX_10514_SK_frame_438.jpg GX_10514_SK_frame_438.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1248.0 3705.0\n20736.0 3456.0493573264794\n20832.0 20495.90128534704\n1392.0 20544.148071979434" | \ gdaltransform -tps -output_xy GX_10514_SK_frame_438.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10514_SK_frame_438.vrt GX_10514_SK_frame_438.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10514_SK_frame_438.cut.vrt GX_10514_SK_frame_438.xyz