Public
Edited
Nov 18, 2022
17 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
z0Raw = FileAttachment("z0_raw_webmercator.tif")
Insert cell
input = await Gdal.open(z0Raw)
Insert cell
Insert cell
Gdal.getInfo(input.datasets[0])
Insert cell
// https://gdal.org/programs/gdalwarp.html#description
options = [
'-of', 'GTiff', // format
'-t_srs', 'EPSG:4326', // destination projection
'-r', 'bilinear', // resampling method
'-co', 'COMPRESS=LZW', // compression method
'-co', 'PREDICTOR=2', // see https://kokoalberti.com/articles/geotiff-compression-optimization-guide/
]
Insert cell
z0_wgs84 = {
const output = await Gdal.gdalwarp(input.datasets[0], options)
return Gdal.getFileBytes(output.local)
}
Insert cell
Insert cell
Gdal.close(input)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// See https://talk.observablehq.com/t/unable-to-import-gdal3-js-a-gdal-port/6732/4 for an explanation
Gdal = new Proxy(await initGdalJs({paths, useWorker: flag('worker')}), {
get(target, prop, receiver) {
if(prop === 'next' || prop === 'then' || prop === 'return') return;
return Reflect.get(target, prop, receiver);
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more