#!/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.58021927 57.38973825 -gcp 15816.0 0.0 26.74258947 57.39579729 -gcp 15816.0 15696.0 26.75252438 57.30775045 -gcp 0.0 15696.0 26.59178495 57.30251146 GX8473/GX_8473_SK_frame_226.jpg GX_8473_SK_frame_226.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2184.0 1511.9732590529247\n14136.0 1151.732590529248\n14448.0 14904.026740947076\n2064.0 14927.906406685237" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_226.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_226.vrt GX_8473_SK_frame_226.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_226.cut.vrt GX_8473_SK_frame_226.xyz