#!/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 26.2340641 57.40110363 -gcp 9978.0 0.0 26.24063015 57.31703803 -gcp 9978.0 10125.0 26.0875833 57.31236295 -gcp 0.0 10125.0 26.07585669 57.39624269 GX8473/GX_8473_SK_frame_217.jpg GX_8473_SK_frame_217.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "528.0 984.0\n9756.0 876.0601671309191\n9780.0 9035.966573816157\n792.0 9108.033426183843" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_217.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_217.vrt GX_8473_SK_frame_217.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_217.cut.vrt GX_8473_SK_frame_217.xyz