#!/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 23.68652344 57.0132627 -gcp 21186.0 0.0 23.86058807 57.03101589 -gcp 21186.0 21369.0 23.8795969 56.92848233 -gcp 0.0 21369.0 23.70287418 56.92408846 GX2206/GX_2206_SK_frame_8.jpg GX_2206_SK_frame_8.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1728.0 2015.5454038997204\n18624.0 1392.1337047353763\n18672.0 20928.0\n1008.0 20831.946518105848" | \ gdaltransform -tps -output_xy GX_2206_SK_frame_8.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_2206_SK_frame_8.vrt GX_2206_SK_frame_8.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_2206_SK_frame_8.cut.vrt GX_2206_SK_frame_8.xyz