#!/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 21.09660387 56.27185987 -gcp 20856.0 0.0 21.09645367 56.24553183 -gcp 20856.0 21510.0 21.04808807 56.24616372 -gcp 0.0 21510.0 21.04901075 56.27175264 GX2694/GX_2694_SG_frame_138.jpg GX_2694_SG_frame_138.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "528.0 2502.0\n20496.0 2015.8662952646237\n20592.0 19583.8930362117\n528.0 19680.16044568245" | \ gdaltransform -tps -output_xy GX_2694_SG_frame_138.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2694_SG_frame_138.vrt GX_2694_SG_frame_138.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2694_SG_frame_138.cut.vrt GX_2694_SG_frame_138.xyz