Subscribe to this thread
Home - General / All posts - MBTiles import
artlembo


3,299 post(s)
#25-Jan-23 04:28

I found this thread related to importing MBTiles into Manifold. Unfortunately, the Reply button is not longer there, so I'm starting a new thread.

I followed the directions for installing the GDAL libraries and adding the paths shown here. It appears to have worked because GDAL is now recognized. But, when attempting to load the file (either as an Import or creating a new data source it returns the error Cannot Load File. For those who have successfully imported the MBTiles into Manifold, I was curious as to what version of the .msi you used from gisinternals.com, or if there were other system changes you had to make.

BTW, QGIS reads the MBTiles just fine - just drag it in, and it shows up.

rk
575 post(s)
#25-Jan-23 06:23

I have gdal v3.3.3 from OSGeo4W (gdal303.dll). I downloaded vectro and raster samples from https://github.com/klokantech/vector-tiles-sample

They open fine.

Attachments:
mbtiles-sample.png

Dimitri


7,145 post(s)
#25-Jan-23 08:30

Using GDAL I just imported a 52MB ncds_06.mbtiles file from the NOAA web site at https://distribution.charts.noaa.gov/ncds/index.html

GDAL obviously did something wrong and, in 45 minutes, generated an image consisting of 2,210,376 tiles that are 256 x 256 x 4, that is 1,198,792 x 120,691 pixels in size, at 4 bytes per pixel amounting to 578 GB. It displays as a blank image.

I can import both the raster and vector sample tiles using GDAL from the link given by rk: https://github.com/klokantech/vector-tiles-sample

The raster tiles come in fine to form an image. However, when GDAL imports the vector tiles, although they form what seem to be correct drawings, the raster image representation of those that GDAL also creates does not display.

adamw


10,281 post(s)
#25-Jan-23 13:57

The NCDS_06 file declares that it covers a huge area, but in reality, the vast majority of the tile references at all levels below top 3 or so are simply absent. For example, the most detailed level consists of just 256 x 128 = 32k tiles, which is much fewer than it would have contained if it was covering the same area as the top level. Further, even of those 32k tiles, around 28k are one of the four variants of 'empty space' (ocean, etc). So, I guess GDAL could be right in creating a huge image with not much data inside and the image could be correctly showing as mostly blank (as in, you have to know where to zoom to see the data).

artlembo


3,299 post(s)
#25-Jan-23 15:25

that's true, there is a lot of wasted space. I think importing, as Dimitri attempted is fruitless - really need to link to it. I brought multiple MBTiles into QGIS, and it displays lightning fast. The next question is how to serve it up (for those asking why, it is because the people I am working with don't want to have to rely on the NOAA server, and want to use it internally).

In the old Manifold 8 way, I would have envisioned linking to the MBTiles, saving the .map file, and serving it as an IMS. Done. If there were a way to read MBTiles in 8, I would go that route.

So, my hope is that 9 will eventually turn into something like this.

I was able to get Geoserver to display it, using the MBTiles plug-in, but that is a bit spotty.

The Manifold approach from 8 is so much easier than other options out there. The only thing missing is the ability to read MBTiles in this case. Hopefully, 9 will have a path there.

artlembo


3,299 post(s)
#25-Jan-23 18:16

I also note that you can change the .mbtiles extension to .sqlite and import it into Manifold. All the information is there, and you can create a new table with

SELECT

 

  map.zoom_level AS zoom_level,

 

 map.tile_column AS tile_column,

 

 map.tile_row AS tile_row,

 

 images.tile_data AS tile_data

 

INTO testtiles

FROM map

 

 JOIN images ON images.tile_id = map.tile_id

the tile_data field comes in as <varbinary 190 b>

is there a way to convert this into a Manifold image?

adamw


10,281 post(s)
#26-Jan-23 12:46

The blobs are files in the format mentioned in the MBTILES data set. They can be written to disk and read back as images using a script.

Dimitri


7,145 post(s)
#26-Jan-23 06:37

how to serve it up

I'd recommend TileServer - they show the NOAA tileset on that page as an example. TileServer is the open source fork of MapBox. MapBox invented MBTiles, so this is using the server for which MBTiles was invented.

artlembo


3,299 post(s)
#27-Jan-23 18:58

that can work. Here is another thought. Using QGIS, I can export the MBTiles as a XYZ directory structure (like OSM and Google). Any thoughts on reading that into 8 or 9? If 8 can read it in, then IMS can show it as a WMS. Similar for 9, I can get prepared with the data, and then sit back and wait until Manifold releases a WMS server in the near future

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.