1#!/bin/bash 2 3# Tool for downloading Vicmap Basemap aerial photography (provided as tiles) 4# and combine into a single file. View maps and determine desired coordinates 5# here - https://mapshare.vic.gov.au/webmap/historical-photomaps/ 6# (turn on "Vicmap Basemap - Aerial") 7 8# Andrew Lorimer - April 2021 9 10usagelong="\e[1mUSAGE:\e[0m 11$(basename "$0")LONGMIN LONGMAX LATMIN LATMAX [[ZOOM] OUTPUT] 12 13\e[1mOPTIONS:\e[0m 14 LONGMIN 15 Minimum longitude 16 17 LONGMAX 18 Maximum longitude 19 20 LATMIN 21 Minimum latitude 22 23 LATMAX 24 Maximum latitude 25 26 ZOOM 27 The zoom level for tiles, 1-20. Zoom 5 captures the whole state in one 28 512x512px tile. Zoom 20 produces 62.44m square tiles at 512x512px. Note 29 coordinates change between zoom levels - the coordinates for the north west 30 corner of each tile are multiplied by two for each increment in zoom level. 31 This accounts for each tile splitting into 4 (i.e. doubling the scale). 32 Default: 20 33 34 OUTPUT 35 Name of file to output to (relative to current directory). 36 Default: vicmap.png 37 38 Inspect Element on map, then find the <div> with the satellite images (element 39 id typically OpenLayers_Layer_XYZ_8). The second last number in each image 40 URL corresponds to the longitude (E-W) and the last number corresponds to the 41 latitude (N-S). Find the maximum latitude and longitude in the range shown.\n" 42 43if(($#<4||$#>6));then 44printf"$usagelong" 45exit 46fi 47zoom="20" 48output="vicmap.png" 49 50longmin=$1 51longmax=$2 52latmin=$3 53latmax=$4 54if(($#==5));then 55 output=$5 56elif(($#==6));then 57 zoom=$5 58 output=$6 59fi 60 61x=$(( $longmax - $longmin + 1)) 62y=$(( $latmax - $latmin + 1)) 63 64mkdir-p .vicmap-tmp 65cd .vicmap-tmp 66 67# Iterate through longitudes (columns) 68for((i=$longmin; i<=$longmax; i++));do 69mkdir-p$i 70# Iterate through latitudes (individual tiles N to S) 71for((j=$latmin; j<=$latmax; j++));do 72 curl -s -C- https://base.maps.vic.gov.au/wmts/AERIAL_WM/EPSG:3857/$zoom/$i/$j.png -o$i/$j.png 73done 74 montage $i/*-tile1x"$y"-geometry+0+0$i.png 75done 76 77montage *.png -tile"$x"x1 -geometry+0+0 ../$output 78 79cd .. 80rm-rf .vicmap-tmp