After a frustrating few days I came to the conclusion that the Slippy Map Wiki only works for raster tiles, not for OSM2VectorTiles data. I can work with the data once I find the correct tile_data BLOB, but actually locating the correct tile via a user lat/long is problematic. The equations given in the wiki above identify raster tiles correctly, but I'm trying to get this working for an offline version of OpenStreetMap rendering/navigation (meaning I can't just use mapbox's JS API to convert it, also I can't find where the conversion happens in the github repo).

Can anyone offer any advice as to how I can convert a lat/long to the correct tile in an OSM2VT SQLite database?

The query, that works for raster tiles, may be of some use:

    public void UserQuery()
        Console.Write("Please enter a latitude value: ");
        double userLat = Convert.ToDouble(Console.ReadLine());
        Console.Write("Please enter a longitude value: ");
        double userLong = Convert.ToDouble(Console.ReadLine());

        _merc.TileLat = Math.Floor((1.0 - Math.Log(Math.Tan(DegreesToRadians(userLat)) + 1.0 / Math.Cos(DegreesToRadians(userLat))) / Math.PI) * Math.Pow(2, ZoomLevel));
        _merc.TileLong = Math.Floor((userLong + 180.0) / 360.0 * Math.Pow(2, ZoomLevel));

1 Answer 1


You may find the following code from tilemaker relevant:


I don't have any experience with osm2vectortiles because I find Docker and npm about as appealing as sandpapering my eyeballs, but I presume it uses the same tile layout.

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.