#!/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.11468983 56.9409478 -gcp 15834.0 0.0 24.11526918 56.91936883 -gcp 15834.0 11655.0 24.08406703 56.91822133 -gcp 0.0 11655.0 24.08406973 56.94191932 GX4141/GX_4141L_frame_27.jpg GX_4141L_frame_27.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "240.0 192.10696378830107\n15720.0 48.02674094707527\n15744.0 11520.695264623955\n264.0 11568.50807799443" | \ gdaltransform -tps -output_xy GX_4141L_frame_27.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4141L_frame_27.vrt GX_4141L_frame_27.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4141L_frame_27.cut.vrt GX_4141L_frame_27.xyz