#!/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 1988.803107457618 4842.730980671623 27.30739295 57.14827128 -gcp 19384.73815805296 6769.667902723153 27.32600212 57.21661162 -gcp 20784.07571639509 19692.240050329663 27.42000818 57.22019795 -gcp 3080.622545600856 20069.232016818947 27.41724014 57.15008126 GX10802/GX_10802_SK_frame_358.jpg GX_10802_SK_frame_358.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "720.0 2454.0\n21072.0 2159.1977715877433\n20928.0 19631.973259052927\n768.0 19584.133704735374" | \ gdaltransform -tps -output_xy GX_10802_SK_frame_358.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10802_SK_frame_358.vrt GX_10802_SK_frame_358.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10802_SK_frame_358.cut.vrt GX_10802_SK_frame_358.xyz