#!/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 23.27872038 56.73557852 -gcp 13902.0 0.0 23.37165356 56.74312791 -gcp 13902.0 13911.0 23.39141607 56.70534194 -gcp 0.0 13911.0 23.30866456 56.68646699 GX5204/GX_5204_SG_frame_573.jpg GX_5204_SG_frame_573.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "96.0 42.0167130919217\n12288.0 83.66573816155915\n12504.0 1188.2674094707527\n13560.0 1344.0267409470753\n13488.0 12660.006685236767\n12456.0 12779.749303621169\n11448.0 13818.010027855154\n27.0 13875.016713091922" | \ gdaltransform -tps -output_xy GX_5204_SG_frame_573.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_5204_SG_frame_573.vrt GX_5204_SG_frame_573.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_5204_SG_frame_573.cut.vrt GX_5204_SG_frame_573.xyz