#!/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 2632.04706790682 3954.96812012581 27.36632109 57.14641456 -gcp 18791.72386006689 4619.6453148774035 27.3783803 57.20962755 -gcp 16598.40401519492 18757.19528163005 27.47680664 57.20013217 -gcp 5174.176322162581 19944.543455474843 27.48586178 57.15407327 GX10802/GX_10802_SK_frame_356.jpg GX_10802_SK_frame_356.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "600.0 2735.9732590529247\n20736.0 2543.6523676880215\n20928.0 19536.133704735377\n624.0 19848.066852367687" | \ gdaltransform -tps -output_xy GX_10802_SK_frame_356.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10802_SK_frame_356.vrt GX_10802_SK_frame_356.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10802_SK_frame_356.cut.vrt GX_10802_SK_frame_356.xyz