azavea / loam

Javascript wrapper for GDAL in the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert (gdal_translate) to mbtiles

LuukMoret opened this issue · comments

Is it possible to convert to mbtiles? I currently have GTiff working but when I try to convert to mbtiles I get an error when calling the bytes() function.

const dataset = await file.convert(['-of', 'GTiff', '-a_srs', 'EPSG:4326', '-a_ullr', upperLeftX, upperLeftY, upperRightX, upperRightY]);
const fileBytes: Uint16Array = await dataset.bytes();
loam.js:1 Uncaught (in promise) Error: Error in GDALTranslate: ZMap: ZMap Plus Grid 
   at Worker.o2.onmessage (loam.js:1) 
   o2.onmessage @ loam.js:1 
   await in o2.onmessage (async)

Currently, not as configured. The GDAL docs specify that GDAL must be compiled with SQLite support in order to support this format. The version of gdal-js that Loam uses by default is not compiled with SQLite support. This is to minimize the bundle size, but it means that some formats are not supported.

It should be possible to make a custom build of gdal-js that supports SQLite, and use it to create mbtiles. I know that other people have used Emscripten to compile SQLite, so I don't know of any reason it wouldn't work in this case as well, but I haven't tried it myself.

Alright great, thanks for the quick answer!