#!/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 2315.809930760982 2858.801198210384 25.01660943 57.26600872 -gcp 20509.755185316622 2550.5092820444215 25.01538634 57.3387864 -gcp 20478.949663930784 18592.966192540884 25.1338166 57.33814437 -gcp 1160.7304797855088 18817.194872570595 25.1369977 57.26150104 GX8464/GX_8464_SK_frame_281.jpg GX_8464_SK_frame_281.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "552.0 2423.8529247910865\n360.0 19200.133704735377\n20808.0 19732.973816155987\n20928.0 2208.2406685236765" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_281.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_281.vrt GX_8464_SK_frame_281.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_281.cut.vrt GX_8464_SK_frame_281.xyz