#!/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.64608454 57.73088133 -gcp 10842.0 0.0 22.57776797 57.73819554 -gcp 10842.0 10800.0 22.58514701 57.77139158 -gcp 0.0 10800.0 22.65446084 57.76993147 GX18588/GX_18588_SK_frame_081.jpg GX_18588_SK_frame_081.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "960.0 1539.0\n10176.0 1368.2139275766021\n10128.0 9479.986629526464\n1056.0 9456.187186629526" | \ gdaltransform -tps -output_xy GX_18588_SK_frame_081.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18588_SK_frame_081.vrt GX_18588_SK_frame_081.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18588_SK_frame_081.cut.vrt GX_18588_SK_frame_081.xyz