#!/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 26.11725926 57.40165889 -gcp 9993.0 0.0 26.13098145 57.31722962 -gcp 9993.0 10191.0 25.97670078 57.3106479 -gcp 0.0 10191.0 25.96277475 57.39204507 GX8473/GX_8473_SK_frame_215.jpg GX_8473_SK_frame_215.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "612.0 1008.0\n9816.0 888.1069637883007\n9768.0 9180.147075208914\n780.0 9192.153760445683" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_215.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_215.vrt GX_8473_SK_frame_215.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_215.cut.vrt GX_8473_SK_frame_215.xyz