#!/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.03376162989114 57.04552789854171 -gcp 21600.0 0.0 24.05848599703612 57.05035012897196 -gcp 21600.0 21729.0 24.06739527594282 57.03685659977541 -gcp 0.0 21729.0 24.04247933180171 57.03194623224588 GX4799/GX_4799_SD_frame_92.jpg GX_4799_SD_frame_92.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "1440.0 2688.0\n1488.0 19536.0\n21216.0 19920.0\n21168.0 4740.0\n20640.0 2868.0" | \ gdaltransform -tps -output_xy GX_4799_SD_frame_92.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4799_SD_frame_92.vrt GX_4799_SD_frame_92.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4799_SD_frame_92.cut.vrt GX_4799_SD_frame_92.xyz