#!/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.72505897 57.56688425 -gcp 17754.0 0.0 22.66804994 57.54106356 -gcp 17754.0 17817.0 22.62173105 57.57180058 -gcp 0.0 17817.0 22.67871661 57.5957822 GX18588/GX_18588_SK_frame_69.jpg GX_18588_SK_frame_69.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "4272.0 1992.0\n4296.0 15744.0\n16464.0 15576.0\n16080.0 1728.0" | \ gdaltransform -tps -output_xy GX_18588_SK_frame_69.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_18588_SK_frame_69.vrt GX_18588_SK_frame_69.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_18588_SK_frame_69.cut.vrt GX_18588_SK_frame_69.xyz