#!/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.35648561 57.1906111 -gcp 21756.0 0.0 24.30566311 57.2030845 -gcp 21756.0 21510.0 24.33085442 57.22771667 -gcp 0.0 21510.0 24.37956333 57.21507731 GX4477/GX_4477L_SD_frame_161.jpg GX_4477L_SD_frame_161.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "768.0 2262.0\n21168.0 2447.705849582172\n20976.0 19008.267409470755\n1056.0 18960.454596100277" | \ gdaltransform -tps -output_xy GX_4477L_SD_frame_161.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4477L_SD_frame_161.vrt GX_4477L_SD_frame_161.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4477L_SD_frame_161.cut.vrt GX_4477L_SD_frame_161.xyz