#!/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 27.25996913 57.40911006 -gcp 18063.0 0.0 27.26763757 57.30811049 -gcp 18063.0 18003.0 27.08675046 57.30201428 -gcp 0.0 18003.0 27.06978176 57.40323221 GX8473/GX_8473_SK_frame_235.jpg GX_8473_SK_frame_235.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2520.0 3336.0\n2880.0 15408.0\n16176.0 15480.0\n16320.0 2976.0" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_235.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_235.vrt GX_8473_SK_frame_235.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_235.cut.vrt GX_8473_SK_frame_235.xyz