#!/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.24691891 56.96964029 -gcp 21600.0 0.0 24.2103037 56.99357251 -gcp 21600.0 21168.0 24.25452574 57.01403748 -gcp 0.0 21168.0 24.29104688 56.98883235 GX4190/GX_4190_SD_frame_9.jpg GX_4190_SD_frame_9.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "696.0 2424.2401334074484\n672.0 18840.426903835465\n21048.0 18935.77320733741\n21000.0 2207.8132295719843" | \ gdaltransform -tps -output_xy GX_4190_SD_frame_9.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4190_SD_frame_9.vrt GX_4190_SD_frame_9.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4190_SD_frame_9.cut.vrt GX_4190_SD_frame_9.xyz