#!/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 23.73112705 56.67237813 -gcp 31752.0 0.0 23.75249045 56.65900528 -gcp 31752.0 23880.0 23.73358084 56.64842145 -gcp 0.0 23880.0 23.70999761 56.66361072 GX4141/GX_4141L_frame_7.jpg GX_4141L_frame_7.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "612.0 468.03335186214576\n504.0 23328.053362979437\n31128.0 23519.98665925514\n31320.0 431.90661478599213" | \ gdaltransform -tps -output_xy GX_4141L_frame_7.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4141L_frame_7.vrt GX_4141L_frame_7.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4141L_frame_7.cut.vrt GX_4141L_frame_7.xyz