#!/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 21.56620502 57.41655693 -gcp 21564.0 0.0 21.58955097 57.39188909 -gcp 21564.0 21315.0 21.54531148 57.37963164 -gcp 0.0 21315.0 21.52140141 57.40469902 GX2297/GX_2297_SD_frame_100.jpg GX_2297_SD_frame_100.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "2160.0 822.0\n20736.0 960.3208913649032\n21120.0 20448.133704735374\n2544.0 20688.053481894152" | \ gdaltransform -tps -output_xy GX_2297_SD_frame_100.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2297_SD_frame_100.vrt GX_2297_SD_frame_100.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2297_SD_frame_100.cut.vrt GX_2297_SD_frame_100.xyz