#!/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 2318.7394104614896 3127.0224323477655 25.43580651 57.26769698 -gcp 18068.4465133569 7187.947162563034 25.46998858 57.32876851 -gcp 18869.488247909358 18049.41237821569 25.54932833 57.3303957 -gcp 1717.4222718901947 18014.724733715157 25.54484367 57.26331538 GX8464/GX_8464_SK_frame_274.jpg GX_8464_SK_frame_274.vrt # Add cutline to VRT gdalwarp -r $GDAL_SAMPLING_WARP -tps -dstalpha -cutline_srs EPSG:4326 \ -cutline "POLYGON(($(echo -e "480.0 2639.8395543175484\n20928.0 2448.080222841226\n20928.0 19248.240668523675\n624.0 19296.90919220056" | \ gdaltransform -tps -output_xy GX_8464_SK_frame_274.vrt | \ awk 'NR==1{first=$0} {printf "%s %s,", $1,$2} END{print " " first}')))" \ GX_8464_SK_frame_274.vrt GX_8464_SK_frame_274.cut.vrt # Generate tiles gdal2tiles.py -r $GDAL_SAMPLING_TILE --xyz -z $GDAL_TILE_ZOOMS -x --processes=$GDAL_TILE_PROCESSES GX_8464_SK_frame_274.cut.vrt GX_8464_SK_frame_274.xyz