#!/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 22.28229271 57.70330501 -gcp 10836.0 0.0 22.30993867 57.667459 -gcp 10836.0 10800.0 22.24898815 57.65404651 -gcp 0.0 10800.0 22.21643912 57.68826638 GX18588/GX_18588_SK_frame_093.jpg GX_18588_SK_frame_093.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1056.0 1395.0\n10128.0 1247.8395543175484\n10104.0 9768.307520891365\n1668.0 9762.023398328689\n1488.0 9215.893036211699\n888.0 9096.187186629526" | \ gdaltransform -tps -output_xy GX_18588_SK_frame_093.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18588_SK_frame_093.vrt GX_18588_SK_frame_093.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18588_SK_frame_093.cut.vrt GX_18588_SK_frame_093.xyz