#!/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 25.34788907 57.31830729 -gcp 15168.0 0.0 25.31573474 57.33180023 -gcp 15168.0 6414.0 25.32640189 57.33933372 -gcp 0.0 6414.0 25.35881102 57.32574799 GX4190/c_GX_4190_SD_frame_77_1.jpg c_GX_4190_SD_frame_77_1.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "0.0 0.0\n0.0 6411.0\n15165.0 6411.0\n15165.0 0.0" | \ gdaltransform -tps -output_xy c_GX_4190_SD_frame_77_1.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ c_GX_4190_SD_frame_77_1.vrt c_GX_4190_SD_frame_77_1.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES c_GX_4190_SD_frame_77_1.cut.vrt c_GX_4190_SD_frame_77_1.xyz