#!/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 2898.758364541777 3605.831446762869 25.18083572 55.9103279 -gcp 16647.0685982476 2453.9091742912237 25.21420777 55.91099964 -gcp 19064.47067772477 17719.670446761706 25.21910548 55.88956977 -gcp 2469.4318212287226 18904.665697910554 25.17736763 55.88908548 GX4599/GX_4599_SD_frame_119.jpg GX_4599_SD_frame_119.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "912.0 2352.1337047353763\n21264.0 2352.0534818941505\n21288.0 19295.973259052924\n960.0 19344.401114206128" | \ gdaltransform -tps -output_xy GX_4599_SD_frame_119.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_4599_SD_frame_119.vrt GX_4599_SD_frame_119.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_4599_SD_frame_119.cut.vrt GX_4599_SD_frame_119.xyz