#!/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 25.28752327 57.07132617 -gcp 14181.0 0.0 25.44558996 57.07744811 -gcp 14181.0 14679.0 25.4556301 56.9903861 -gcp 0.0 14679.0 25.29975414 56.98392801 GX220/GX_220_SK_frame_577.jpg GX_220_SK_frame_577.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1512.0 383.9598885793871\n12720.0 288.0\n13104.0 14040.066852367687\n1512.0 14112.093593314763" | \ gdaltransform -tps -output_xy GX_220_SK_frame_577.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_220_SK_frame_577.vrt GX_220_SK_frame_577.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_220_SK_frame_577.cut.vrt GX_220_SK_frame_577.xyz