Here's a simple way to create your own global 30 meter or CONUS 10 meter elevation service without any local DEM rasters. It uses only Cloud Native GeoTiff's (COG) hosted on AWS S3. All you need is GDAL, no other software or dependencies.
Let's start with building a global file list of Copernicus 30 meter DEM's. Since we need to read the meta data from 1000's of DEM's, this will take a very long time to create. But, you only need to do it once.
# Copernicus keeps a list of DEM directories, let's grab it:
gdal vsi copy /vsis3/copernicus-dem-30m/tileList.txt .
# Next, we need to build an absolute path to the .tif files only, skipping all other files in the directory:
cat tileList.txt | tr -d "\r" | awk '{printf("/vsis3/copernicus-dem-30m/%s/%s.tif\n", $0, $0);}' > s3.txt
# Now, the time consuming part. Read the meta data from each remote .tif and save it as a single, virtual DEM:
time gdal raster mosaic \
-i @s3.txt \
--resolution lowest \
--absolute-path \
-o copernicusDEM.vrt
real 219m0.284s
user 2m27.856s
sys 0m13.939s
If you only want elevation data from the U.S. we can do the same with 10 meter data. The good news is, the .vrt is already built, located on the remote server. It can be found here.
/vsis3/prd-tnm/StagedProducts/Elevation/13/TIFF/USGS_Seamless_DEM_13.vrt
Using the U.S. DEM's, let's grab some elevation data and display it:
gdal raster pixel-info \
-i /vsis3/prd-tnm/StagedProducts/Elevation/13/TIFF/USGS_Seamless_DEM_13.vrt \
--position-crs EPSG:4326 \
--of CSV \
-120.321 40.123
# The output will look like:
input_x,input_y,extra_input,column,line,band_1_raw_value,band_1_unscaled_value
-120.321,40.122999999999998,"",644539.19953505183,344277.59975768777,2026.3131103515625,2026.3131103515625
If you need to get more than 1 coordinate (batch), you can create a file with 1 coordinate per line and use that as a source. If you want to save the elevation data, redirect it to an output file.
gdal raster pixel-info \
-i /vsis3/prd-tnm/StagedProducts/Elevation/13/TIFF/USGS_Seamless_DEM_13.vrt \
--position-crs EPSG:4326 \
--resampling bilinear \
--of CSV \
< coords.txt > output.csv
That's it!