#!/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 27.60714054 56.94987782 -gcp 21498.0 0.0 27.61358857 56.97897624 -gcp 21498.0 21381.0 27.66629601 56.97654946 -gcp 0.0 21381.0 27.66281247 56.94558278 GX4798/GX_4798_SD_frame_14.jpg GX_4798_SD_frame_14.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "768.0 2063.919777158774\n2436.0 1872.233983286908\n2508.0 671.4584958217272\n17400.0 503.43844011142073\n17424.0 2795.993314763231\n20832.0 2808.040111420613\n20880.0 19295.759331476325\n1152.0 19007.572144846796" | \ gdaltransform -tps -output_xy GX_4798_SD_frame_14.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4798_SD_frame_14.vrt GX_4798_SD_frame_14.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4798_SD_frame_14.cut.vrt GX_4798_SD_frame_14.xyz