#!/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.26950955 57.29561387 -gcp 21048.0 0.0 25.20171404 57.29356753 -gcp 21048.0 21123.0 25.19847347 57.3331986 -gcp 0.0 21123.0 25.27031422 57.33047114 GX954/GX_954L_SG_frame_6.jpg GX_954L_SG_frame_6.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "576.0 1751.9466370205666\n20832.0 1679.69316286826\n20736.0 19223.91995553085\n360.0 18911.93329627571" | \ gdaltransform -tps -output_xy GX_954L_SG_frame_6.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_954L_SG_frame_6.vrt GX_954L_SG_frame_6.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_954L_SG_frame_6.cut.vrt GX_954L_SG_frame_6.xyz