#!/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.25169706 57.13547664 -gcp 22014.0 0.0 24.206357 57.15560963 -gcp 22014.0 21639.0 24.24455695 57.17906719 -gcp 0.0 21639.0 24.28538561 57.15637772 GX4477/GX_4477L_SD_frame_156.jpg GX_4477L_SD_frame_156.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "960.0 2502.0\n21504.0 2735.7593314763226\n21216.0 19488.294150417823\n1056.0 19248.133704735374" | \ gdaltransform -tps -output_xy GX_4477L_SD_frame_156.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4477L_SD_frame_156.vrt GX_4477L_SD_frame_156.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4477L_SD_frame_156.cut.vrt GX_4477L_SD_frame_156.xyz