#!/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 21.12748146 56.27102585 -gcp 20919.0 0.0 21.12683764 56.24595745 -gcp 20919.0 21897.0 21.07734947 56.24501543 -gcp 0.0 21897.0 21.07812881 56.27172881 GX2694/GX_2694_SG_frame_137.jpg GX_2694_SG_frame_137.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 2790.0\n20400.0 2592.6150417827284\n20496.0 19824.267409470755\n672.0 19920.08022284122" | \ gdaltransform -tps -output_xy GX_2694_SG_frame_137.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2694_SG_frame_137.vrt GX_2694_SG_frame_137.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2694_SG_frame_137.cut.vrt GX_2694_SG_frame_137.xyz