#!/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 25.99056244 56.13502876 -gcp 14118.0 0.0 25.95307589 56.0512265 -gcp 14118.0 14169.0 25.89712389 56.05711098 -gcp 0.0 14169.0 25.87975502 56.15692779 GX4648/GX_4648_SD_frame_92.jpg GX_4648_SD_frame_92.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "3192.0 1727.7860724233985\n13848.0 1823.4384401114207\n13680.0 13824.788857938718\n3264.0 13703.973259052924" | \ gdaltransform -tps -output_xy GX_4648_SD_frame_92.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4648_SD_frame_92.vrt GX_4648_SD_frame_92.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4648_SD_frame_92.cut.vrt GX_4648_SD_frame_92.xyz