NZ DEM
The 8m NZ DEM is an interpolation of the 20m contours on the 1:50,000 scale LINZ topo maps.
Coverage
The datasets covers all of New Zealand except Chatham Island at an 8 metre resolution.
NZ DEM elevation rendering.
Adding NZ DEM to Open Topo Data
mkdir ./data/nzdem8m
As of May 2020, the 8m dataset could only be painstaking downloaded a single tile at a time through the LINZ web interface. If you'd rather not do this send me an email, I can send you the raw dataset.
Once you've obtained the 115 files, unzip the zip archives and delete anything without a .tif
extension.
For Open Topo Data to understand the grid arrangement of the files, they need to be renamed to the coordinates of the lower-left corner. Here's the Python script I used, I'm also adding a buffer to help with interpolation near tile borders:
import os from glob import glob folder = './data/nzdem8m' # Build vrt for all tifs. pattern = os.path.join(folder, '*.tif') tif_paths = list(glob(pattern)) vrt_path = os.path.join(folder, 'all.vrt') assert not os.system('gdalbuildvrt {} {}'.format(vrt_path, ' '.join(tif_paths))) buffer_ = 5 for tif_path in tif_paths: with rasterio.open(tif_path) as f: new_bounds = ( f.bounds.left - buffer_ * f.res[0], f.bounds.bottom - buffer_ * f.res[1], f.bounds.right + buffer_ * f.res[0], f.bounds.top + buffer_ * f.res[1], ) new_shape = ( f.shape[0] + buffer_ * 2, f.shape[1] + buffer_ * 2, ) northing = f.bounds.bottom easting = f.bounds.left filename = 'N{}E{}.tif'.format(int(northing), int(easting)) buffer_path = os.path.join(os.path.dirname(tif_path), filename) te = ' '.join(str(x) for x in new_bounds) ts = ' '.join(str(x) for x in new_shape) cmd = f'gdalwarp -te {te} -ts {ts} -r near -co NUM_THREADS=ALL_CPUS -co COMPRESS=DEFLATE -co PREDICTOR=3 {vrt_path} {buffer_path}' assert not os.system(cmd) assert not os.system(f'rm {vrt_path}')
Create a config.yaml
file, setting the size of the tiles (65536 metres) and the projection system used (NZ tranverse mercator):
datasets: - name: nzdem8m path: data/nzdem8m/ filename_tile_size: 65536 filename_epsg: 2193
Rebuild to enable the new dataset at localhost:5000/v1/nzdem8m.
make build && make run
Public API
The Open Topo Data public API lets you query NZ DEM 8m for free:
curl https://api.opentopodata.org/v1/nzdem8m?locations=-37.86118,174.79974
{ "results": [ { "elevation": 705.4374389648438, "location": { "lat": -37.86118, "lng": 174.79974 } } ], "status": "OK" }
The data files used in the public API were downloaded from LINZ May 2020.