#!/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.21184206 57.34407828 -gcp 21177.0 0.0 25.28650388 57.33933016 -gcp 21177.0 21702.0 25.27613982 57.29527698 -gcp 0.0 21702.0 25.19924641 57.30500355 GX954/GX_954L_SG_frame_128.jpg GX_954L_SG_frame_128.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "672.0 2543.9466370205673\n21096.0 2135.9599777654257\n21144.0 19559.98665925514\n576.0 19488.02668148972" | \ gdaltransform -tps -output_xy GX_954L_SG_frame_128.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_954L_SG_frame_128.vrt GX_954L_SG_frame_128.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_954L_SG_frame_128.cut.vrt GX_954L_SG_frame_128.xyz