Skip to content

Commit 36643eb

Browse files
committed
Document new EUDEM download
1 parent 6188f76 commit 36643eb

File tree

1 file changed

+8
-114
lines changed

1 file changed

+8
-114
lines changed

docs/datasets/eudem.md

+8-114
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,25 @@ The advantage of the `NODATA` oceans is that you cane use EU-DEM without clippin
3030

3131
## Adding EU-DEM to Open Topo Data
3232

33+
As of Jan 2024, EU-DEM is no longer available to download via copernicus.eu.
3334

34-
Make a new folder for the dataset:
35+
I have uploaded my version of the dataset at [https://files.gpxz.io/eudem_buffered.zip](https://files.gpxz.io/eudem_buffered.zip), see [EUDEM download](https://www.gpxz.io/blog/eudem) for more details.
3536

36-
```bash
37-
mkdir ./data/eudem
38-
```
39-
40-
Download the dataset from [Copernicus](https://land.copernicus.eu/imagery-in-situ/eu-dem/eu-dem-v1.1?tab=download). There are 27 files. Unzip them and move all the `.TIF` files into the data folder (you don't need the `.aux.xml`, `.ovr`, or `.TFw` files).
41-
42-
Your data folder should now contain only 27 TIF files:
37+
Download and unzip the folder into:
4338

4439
```bash
45-
ls ./data/eudem
46-
47-
# eu_dem_v11_E00N20.TIF
48-
# eu_dem_v11_E10N00.TIF
49-
# eu_dem_v11_E10N10.TIF
50-
# ...
51-
```
52-
53-
54-
If you have [gdal](https://gdal.org) installed, the easiest thing to do here is build a [VRT](https://gdal.org/drivers/raster/vrt.html) - a single raster file that links to the 27 tiles and which Open Topo Data can treat as a single-file dataset.
55-
56-
```bash
57-
mkdir ./data/eudem-vrt
58-
cd ./data/eudem-vrt
59-
gdalbuildvrt -tr 25 25 -tap -te 0 0 8000000 6000000 eudem.vrt ../eudem/*.TIF
60-
cd ../../
40+
mkdir ./data/eudem
6141
```
62-
63-
The `tr`, `tap`, and `te` options in the above command ensure that slices from the VRT will use the exact values and grid of the source rasters.
64-
42+
There are 27 files.
6543

6644
Then create a `config.yaml` file:
6745

6846
```yaml
6947
datasets:
7048
- name: eudem25m
71-
path: data/eudem-vrt/
49+
path: data/eudem
50+
filename_epsg: 3035
51+
filename_tile_size: 1000000
7252
```
7353
7454
Finally, rebuild to enable the new dataset at [localhost:5000/v1/eudem25m?locations=51.575,-3.220](http://localhost:5000/v1/eudem25m?locations=51.575,-3.220).
@@ -82,92 +62,6 @@ make build && make run
8262
If you don't have gdal installed, you can use the tiles directly. There are instructions for this [here](https://github.com/ajnisbet/opentopodata/blob/f012ec136bebcd97e1dc05645e91a6d2487127dc/docs/datasets/eudem.md#adding-eu-dem-to-open-topo-data), but because the EU-DEM tiles don't come with an overlap you will get a `null` elevation at locations within 0.5 pixels of tile edges.
8363

8464

85-
### Buffering tiles (optional)
86-
87-
The tiles provided by EU-DEM don't overlap and cover slightly less than a 1000km square. This means you'll get a `null` result for coordinates along the tile edges.
88-
89-
The `.vrt` approach above solves the overlap issue, but for improved performance you can leave the tiles separate and add a buffer to each one. This is the code I used on the public API to do this:
90-
91-
92-
```python
93-
import os
94-
from glob import glob
95-
import subprocess
96-
97-
import rasterio
98-
99-
100-
# Prepare paths.
101-
input_pattern = 'data/eudem/*.TIF'
102-
input_paths = sorted(glob(input_pattern))
103-
assert input_paths
104-
vrt_path = 'data/eudem-vrt/eudem.vrt'
105-
output_dir = 'data/eudem-buffered/'
106-
os.makedirs(output_dir, exist_ok=True)
107-
108-
109-
110-
# EU-DEM specific options.
111-
tile_size = 1_000_000
112-
buffer_size = 50
113-
114-
for input_path in input_paths:
115-
116-
# Get tile bounds.
117-
with rasterio.open(input_path) as f:
118-
bottom = int(f.bounds.bottom)
119-
left = int(f.bounds.left)
120-
121-
# For EU-DEM only: round this partial tile down to the nearest tile_size.
122-
if left == 943750:
123-
left = 0
124-
125-
# New tile name in SRTM format.
126-
output_name = 'N' + str(bottom).zfill(7) + 'E' + str(left).zfill(7) + '.TIF'
127-
output_path = os.path.join(output_dir, output_name)
128-
129-
# New bounds.
130-
xmin = left - buffer_size
131-
xmax = left + tile_size + buffer_size
132-
ymin = bottom - buffer_size
133-
ymax = bottom + tile_size + buffer_size
134-
135-
# EU-DEM tiles don't cover negative locations.
136-
xmin = max(0, xmin)
137-
ymin = max(0, ymin)
138-
139-
# Do the transformation.
140-
cmd = [
141-
'gdal_translate',
142-
'-a_srs', 'EPSG:3035', # EU-DEM crs.
143-
'-co', 'NUM_THREADS=ALL_CPUS',
144-
'-co', 'COMPRESS=DEFLATE',
145-
'-co', 'BIGTIFF=YES',
146-
'--config', 'GDAL_CACHEMAX','512',
147-
'-projwin', str(xmin), str(ymax), str(xmax), str(ymin),
148-
vrt_path, output_path,
149-
]
150-
r = subprocess.run(cmd)
151-
r.check_returncode()
152-
```
153-
154-
These new files can be used in Open Topo Data with the following `config.yaml` file
155-
156-
157-
```yaml
158-
datasets:
159-
- name: eudem25m
160-
path: data/eudem-buffered/
161-
filename_epsg: 3035
162-
filename_tile_size: 1000000
163-
```
164-
165-
and rebuilding:
166-
167-
```bash
168-
make build && make run
169-
```
170-
17165

17266

17367
## Public API

0 commit comments

Comments
 (0)