Skip to content
No description or website provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

MBTiles Extractor Sample for WPF


The MBTiles Extractor allows you to create new smaller subsets from the MBTiles database. You simply specify the bounding box by tracking a rectangle shape on the map for the new area, then it will create a new SQLite database for that regions.

*.MBTile format can be supported in all of the Map Suite controls such as Wpf, Web, MVC, WebApi, Android and iOS.

Please refer to Wiki for the details.



This sample makes use of the following NuGet Packages

MapSuite 10.5.0

About the Code

var targetDBConnection = new SqliteConnection($"Data Source={targetFilePath}");
var targetMap = new Map(targetDBConnection);
var targetImages = new Images(targetDBConnection);
var targetMetadata = new Metadata(targetDBConnection);

var sourceDBConnection = new SqliteConnection("Data Source=Data/tiles_Frisco.mbtiles");
var sourceMap = new Map(sourceDBConnection);
var sourceImages = new Images(sourceDBConnection);
var sourceMetadata = new Metadata(sourceDBConnection);

foreach (MetadataEntry entry in sourceMetadata.Entries)
    if (entry.Name.Equals("center"))
        PointShape centerPoint = projection.ConvertToExternalProjection(bbox).GetCenterPoint();
        entry.Value = $"{centerPoint.X},{centerPoint.Y},{maxZoom}";

int recordLimit = 1000;
foreach (var tileRange in tileRanges)
    long offset = 0;
    bool isEnd = false;
    while (!isEnd)
        string querySql = $"SELECT * FROM {sourceMap.TableName} WHERE " + ConvetToSqlString(tileRange) + $" LIMIT {offset},{recordLimit}";
        var entries = sourceMap.Query(querySql);

        if (entries.Count < recordLimit)
            isEnd = true;

        querySql = $"SELECT images.tile_data as tile_data, images.tile_id as tile_id FROM {sourceImages.TableName} WHERE images.tile_id IN ( SELECT {Map.TileIdColumnName} FROM {sourceMap.TableName} WHERE " + ConvetToSqlString(tileRange) + $" LIMIT {offset},{recordLimit} )";
        entries = sourceImages.Query(querySql);

        offset = offset + recordLimit;

Getting Help

Map Suite UI Control for WPF Wiki Resources

Map Suite UI Control for WPF Product Description

ThinkGeo Community Site

ThinkGeo Web Site

Key APIs

This example makes use of the following APIs:


About Map Suite

Map Suite is a set of powerful development components and services for the .Net Core.

About ThinkGeo

ThinkGeo is a GIS (Geographic Information Systems) company founded in 2004 and located in Frisco, TX. Our clients are in more than 40 industries including agriculture, energy, transportation, government, engineering, software development, and defense.

You can’t perform that action at this time.