#!/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.07439232 57.01307578 -gcp 21369.0 0.0 24.11356853 56.9151543 -gcp 21369.0 21381.0 23.92913542 56.90371874 -gcp 0.0 21381.0 23.90813828 56.99428545 GX2206/GX_2206_SK_frame_15.jpg GX_2206_SK_frame_15.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "480.0 2783.49192200557\n20808.0 2675.9665738161557\n20928.0 19536.534818941505\n888.0 19080.33426183844" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_15.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_15.vrt GX_2206_SK_frame_15.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_15.cut.vrt GX_2206_SK_frame_15.xyz