#!/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 26.29549742 57.40049015 -gcp 10062.0 0.0 26.2953043 57.31494767 -gcp 10062.0 10095.0 26.14349245 57.31343687 -gcp 0.0 10095.0 26.13605924 57.39735796 GX8473/GX_8473_SK_frame_218.jpg GX_8473_SK_frame_218.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "468.0 923.9599777654252\n9816.0 792.0\n9828.0 9060.053362979434\n324.0 8976.100055586438" | \ gdaltransform -tps -output_xy GX_8473_SK_frame_218.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8473_SK_frame_218.vrt GX_8473_SK_frame_218.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8473_SK_frame_218.cut.vrt GX_8473_SK_frame_218.xyz