#!/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 25.5719535 57.04195487 -gcp 43200.0 0.0 25.57918038 57.12641649 -gcp 43200.0 46686.0 25.74613233 57.12372457 -gcp 0.0 46686.0 25.74154031 57.03743294 GX10525/GX_10525_SK_frame_513.jpg GX_10525_SK_frame_513.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "3312.0 6192.0\n3360.0 40032.0\n41904.0 40272.0\n42048.0 6240.0" | \ gdaltransform -tps -output_xy GX_10525_SK_frame_513.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_10525_SK_frame_513.vrt GX_10525_SK_frame_513.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_10525_SK_frame_513.cut.vrt GX_10525_SK_frame_513.xyz