The data is not simply readable when I open the mbtiles in SQLite db browser. i.e. It's like this: enter image description here

Let's say I want to search for a street name in the mbtiles. GeoServer is already doing this for me when I request a filter through WFS, so I suppose it's possible. I would like to know how to do this using SQL.


1 Answer 1


I managed to write this C# code that does this:

using Microsoft.Data.Sqlite;
using System.IO.Compression;
using VectorTile;

Tile tile;
using var connection = new SqliteConnection(@"Data Source=mymbtiles.mbtiles");
using (var command = new SqliteCommand("SELECT tile_data FROM images WHERE tile_id = '14/10201/9399'", connection))
    using var reader = command.ExecuteReader();
    var stream = reader.GetStream(0);
    using (var decompresser = new GZipStream(stream, CompressionMode.Decompress))
        tile = Tile.Parser.ParseFrom(decompresser);


Before you run you need to compile the Mapbox Vector Tile proto file to get the Tile class. There's a guide on how to do that here, the output directory I used is the same as the Program.cs file. I Installed Microsoft.Data.Sqlite and Google.Protobuf NuGet packages.

Also, as you can see the code is pretty simple you might be able to write it in another language yourself (in case you couldn't get C# to work).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.