#!/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 24.63798409 56.96214841 -gcp 10980.0 0.0 24.80605183 56.9940927 -gcp 10980.0 11160.0 24.85341311 56.8907807 -gcp 0.0 11160.0 24.67760539 56.87526227 GX2261/GX_2261_SK_frame_14.jpg GX_2261_SK_frame_14.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "432.0 2568.0\n10464.0 2591.8261838440108\n10632.0 9768.080222841225\n480.0 9792.093593314763" | \ gdaltransform -tps -output_xy GX_2261_SK_frame_14.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2261_SK_frame_14.vrt GX_2261_SK_frame_14.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2261_SK_frame_14.cut.vrt GX_2261_SK_frame_14.xyz