|
| 1 | +#!/bin/bash |
| 2 | +# Script to download ETOPO 2022 15 arc-second elevation data |
| 3 | +# Data source: NOAA National Centers for Environmental Information |
| 4 | +# DOI: 10.25921/fd45-gt74 |
| 5 | + |
| 6 | +set -e # Exit on error |
| 7 | + |
| 8 | +# Configuration |
| 9 | +# NOTE: Use 15s_surface_elev_netcdf for GLOBAL coverage (288 tiles) |
| 10 | +# Use 15s_bed_elev_netcdf for POLAR bedrock only (60 tiles, high latitudes only) |
| 11 | +DATA_TYPE="${ETOPO_DATA_TYPE:-surface}" # 'surface' or 'bed' |
| 12 | + |
| 13 | +if [ "$DATA_TYPE" = "bed" ]; then |
| 14 | + BASE_URL="https://www.ngdc.noaa.gov/thredds/fileServer/global/ETOPO2022/15s/15s_bed_elev_netcdf" |
| 15 | + FILE_SUFFIX="bed" |
| 16 | +else |
| 17 | + BASE_URL="https://www.ngdc.noaa.gov/thredds/fileServer/global/ETOPO2022/15s/15s_surface_elev_netcdf" |
| 18 | + FILE_SUFFIX="surface" |
| 19 | +fi |
| 20 | + |
| 21 | +OUTPUT_DIR="${1:-./data/etopo_15s}" |
| 22 | + |
| 23 | +# Create output directory |
| 24 | +mkdir -p "$OUTPUT_DIR" |
| 25 | + |
| 26 | +echo "Downloading ETOPO 2022 15 arc-second data to: $OUTPUT_DIR" |
| 27 | +echo "Data type: $DATA_TYPE (files will end with _${FILE_SUFFIX}.nc)" |
| 28 | +echo "==========================================================" |
| 29 | + |
| 30 | +# Option 1: Download ALL tiles (WARNING: This is a LOT of data - 288 tiles!) |
| 31 | +# Uncomment the section below to download everything |
| 32 | + |
| 33 | +download_all_tiles() { |
| 34 | + echo "Downloading all 288 tiles (this will take a while and use significant disk space)..." |
| 35 | + |
| 36 | + # Northern Hemisphere - High Latitude (N60-N90) |
| 37 | + for lat in N60 N75 N90; do |
| 38 | + case $lat in |
| 39 | + N60) |
| 40 | + # N60 tiles |
| 41 | + for lon in W180 W165 W150 W135 W120 W105 W090 W075 W060 W045 W030 W015 \ |
| 42 | + E000 E015 E030 E045 E060 E075 E090 E105 E120 E135 E150 E165; do |
| 43 | + wget -c -P "$OUTPUT_DIR" "${BASE_URL}/ETOPO_2022_v1_15s_${lat}${lon}_${FILE_SUFFIX}.nc" |
| 44 | + done |
| 45 | + ;; |
| 46 | + N75) |
| 47 | + # N75 tiles |
| 48 | + for lon in W180 W165 W150 W135 W120 W105 W090 W075 W060 W045 W030 W015 \ |
| 49 | + E000 E015 E030 E045 E060 E075 E090 E105 E120 E135 E150 E165; do |
| 50 | + wget -c -P "$OUTPUT_DIR" "${BASE_URL}/ETOPO_2022_v1_15s_${lat}${lon}_${FILE_SUFFIX}.nc" |
| 51 | + done |
| 52 | + ;; |
| 53 | + N90) |
| 54 | + # N90 tiles (polar cap - fewer tiles) |
| 55 | + for lon in W180 W165 W150 W135 W120 W105 W090 W075 W060 W045 W030 W015 E000; do |
| 56 | + wget -c -P "$OUTPUT_DIR" "${BASE_URL}/ETOPO_2022_v1_15s_${lat}${lon}_${FILE_SUFFIX}.nc" |
| 57 | + done |
| 58 | + ;; |
| 59 | + esac |
| 60 | + done |
| 61 | + |
| 62 | + # Mid Latitudes (N45, N30, N15, N00) |
| 63 | + for lat in N45 N30 N15 N00; do |
| 64 | + for lon in W180 W165 W150 W135 W120 W105 W090 W075 W060 W045 W030 W015 \ |
| 65 | + E000 E015 E030 E045 E060 E075 E090 E105 E120 E135 E150 E165; do |
| 66 | + wget -c -P "$OUTPUT_DIR" "${BASE_URL}/ETOPO_2022_v1_15s_${lat}${lon}_${FILE_SUFFIX}.nc" |
| 67 | + done |
| 68 | + done |
| 69 | + |
| 70 | + # Southern Hemisphere (S15, S30, S45, S60, S75) |
| 71 | + for lat in S15 S30 S45 S60 S75; do |
| 72 | + for lon in W180 W165 W150 W135 W120 W105 W090 W075 W060 W045 W030 W015 \ |
| 73 | + E000 E015 E030 E045 E060 E075 E090 E105 E120 E135 E150 E165; do |
| 74 | + wget -c -P "$OUTPUT_DIR" "${BASE_URL}/ETOPO_2022_v1_15s_${lat}${lon}_${FILE_SUFFIX}.nc" |
| 75 | + done |
| 76 | + done |
| 77 | +} |
| 78 | + |
| 79 | +# Option 2: Download specific region (RECOMMENDED) |
| 80 | +download_specific_region() { |
| 81 | + echo "Downloading specific region..." |
| 82 | + echo "Edit this function to specify your region of interest" |
| 83 | + |
| 84 | + # Example: Download Europe and North Atlantic region |
| 85 | + # Modify the lat/lon ranges below for your area of interest |
| 86 | + |
| 87 | + # European region example (45N-75N, 15W-45E) |
| 88 | + for lat in N45 N60 N75; do |
| 89 | + for lon in W015 E000 E015 E030 E045; do |
| 90 | + echo "Downloading tile: ${lat}${lon}" |
| 91 | + wget -c -P "$OUTPUT_DIR" "${BASE_URL}/ETOPO_2022_v1_15s_${lat}${lon}_${FILE_SUFFIX}.nc" |
| 92 | + done |
| 93 | + done |
| 94 | +} |
| 95 | + |
| 96 | +# Option 3: Download specific tiles by name |
| 97 | +download_specific_tiles() { |
| 98 | + # Add specific tile names to this array |
| 99 | + local tiles=( |
| 100 | + "N45W120" # US West Coast |
| 101 | + "N45W105" # US Rockies |
| 102 | + "N45E000" # Western Europe |
| 103 | + # Add more tiles as needed |
| 104 | + ) |
| 105 | + |
| 106 | + echo "Downloading ${#tiles[@]} specific tiles..." |
| 107 | + for tile in "${tiles[@]}"; do |
| 108 | + echo "Downloading tile: $tile" |
| 109 | + wget -c -P "$OUTPUT_DIR" "${BASE_URL}/ETOPO_2022_v1_15s_${tile}_${FILE_SUFFIX}.nc" |
| 110 | + done |
| 111 | +} |
| 112 | + |
| 113 | +# Main execution |
| 114 | +echo "" |
| 115 | +echo "Choose download option:" |
| 116 | +echo "1) Download all tiles (WARNING: ~50-100 GB total)" |
| 117 | +echo "2) Download specific region (recommended - edit script first)" |
| 118 | +echo "3) Download specific tiles (edit script to list tiles)" |
| 119 | +echo "" |
| 120 | +read -p "Enter choice [1-3]: " choice |
| 121 | + |
| 122 | +case $choice in |
| 123 | + 1) |
| 124 | + read -p "Are you sure? This will download ~288 files. (yes/no): " confirm |
| 125 | + if [ "$confirm" = "yes" ]; then |
| 126 | + download_all_tiles |
| 127 | + else |
| 128 | + echo "Download cancelled." |
| 129 | + exit 0 |
| 130 | + fi |
| 131 | + ;; |
| 132 | + 2) |
| 133 | + download_specific_region |
| 134 | + ;; |
| 135 | + 3) |
| 136 | + download_specific_tiles |
| 137 | + ;; |
| 138 | + *) |
| 139 | + echo "Invalid choice. Exiting." |
| 140 | + exit 1 |
| 141 | + ;; |
| 142 | +esac |
| 143 | + |
| 144 | +echo "" |
| 145 | +echo "Download complete!" |
| 146 | +echo "Files saved to: $OUTPUT_DIR" |
| 147 | +echo "" |
| 148 | +echo "To use these files, update your paths in setup_paths.sh or local_paths.py" |
| 149 | +echo " export SPEC_APPX_ETOPO_DIR=\"$OUTPUT_DIR\"" |
0 commit comments