#!/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 2225.256045041856 4850.915423851639 27.36680388 57.14627497 -gcp 19347.001651205992 3651.5810741572177 27.36547619 57.21358278 -gcp 18631.710498566114 16650.41698226161 27.45601684 57.20932407 -gcp 4207.614158319955 19970.448219212118 27.47846961 57.15162346 GX10802/GX_10802_SK_frame_357.jpg GX_10802_SK_frame_357.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 2451.0\n21024.0 2351.919777158774\n20664.0 19728.0\n648.0 19608.026740947076" | \ gdaltransform -tps -output_xy GX_10802_SK_frame_357.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10802_SK_frame_357.vrt GX_10802_SK_frame_357.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10802_SK_frame_357.cut.vrt GX_10802_SK_frame_357.xyz