I have been tasked with looking at some code that converts .tif files to .mbtiles and stores them in sql lite database. The code has a bug where when converting from .tif to mbtiles the map when requested is ‘out of order.’ I have been learning gdal along the way and have run out of things to try.
Looking at the gdal documentation it seems we are doing it correctly:
GDALAllRegister();
GDALDataset* geoTiffDataset = (GDALDataset*)GDALOpen("temp.tif", GA_ReadOnly);
GDALDriver* mbtilesDriver = GetGDALDriverManager()->GetDriverByName("MBTiles");
GDALDataset* mbtilesDataset = mbtilesDriver->CreateCopy(outputMBTilesPath.c_str(), geoTiffDataset, FALSE, papszOptions, pfnProgress, progress.get());
GDALClose(geoTiffDataset);
GDALClose(mbtilesDataset);
When converting files an error will pop up that I haven’t been able to track down, but seems like it is occurring in gdal somewhere:
ERROR 1 : Proj: webmerc : invalid latitude
I did see you can use:
GDALDataset* poDstDS = (GDALDataset*)GDALTranslate(outputMBTilesPath.c_str(), geoTiffDataset, psOptions, NULL);
I tried using the above. Very similar to the create copy function, but got the same results with the out of order map.
I’m at a loss. I’m not sure if it’s some kind of configuration issue or not.
out of order map
Kapolani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.