#!/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 24.47384834 57.70068475 -gcp 21177.0 0.0 24.33791399 57.71183919 -gcp 21177.0 21123.0 24.35258144 57.7893504 -gcp 0.0 21123.0 24.50431824 57.77621096 GX4194/GX_4194_SG_frame_3.jpg GX_4194_SG_frame_3.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2766.0 20106.0\n2568.0 19524.0\n2160.0 19146.0\n1482.0 19020.0\n612.0 19080.0\n591.0 11817.0\n765.0 11355.0\n750.0 10143.0\n540.0 9681.0\n390.0 1974.0\n2346.0 1968.0\n2304.0 672.0\n10554.0 408.0\n14910.0 480.0\n21108.0 228.0\n21090.0 20991.0\n10434.0 20985.0\n2772.0 20940.0" | \ gdaltransform -tps -output_xy GX_4194_SG_frame_3.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4194_SG_frame_3.vrt GX_4194_SG_frame_3.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4194_SG_frame_3.cut.vrt GX_4194_SG_frame_3.xyz