#!/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.95155239 57.71088782 -gcp 20982.0 0.0 25.8517313 57.77163395 -gcp 20982.0 21510.0 25.97811699 57.84749171 -gcp 0.0 21510.0 26.10355854 57.76286734 GX8196/GX_8196_SK_frame_24.jpg GX_8196_SK_frame_24.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "288.0 2454.0\n20688.0 2111.9732590529247\n20496.0 19199.866295264626\n384.0 19200.213927576602" | \ gdaltransform -tps -output_xy GX_8196_SK_frame_24.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8196_SK_frame_24.vrt GX_8196_SK_frame_24.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8196_SK_frame_24.cut.vrt GX_8196_SK_frame_24.xyz