0

Is it possible to combine two vector mbtiles files using just SQLite?

I noticed this question Joining several raster .mbtiles? but it does not seem to work with vector files.

I also came across this script Patch mbtiles which seems to support the idea that it should be possible.

In my use case, I want to be able to merge mbtiles on the client side (in a Cordova app with sqlite) without having to involve any operations on the server.

For testing I have two .mbtiles, one covering Maryland and another covering Pennsylvania. Both contain the same layers and zoom levels.

If I merge the map and images tables as shown in the patch file above and view the resulting map in mapbox gl js, there is over a hundred mile gap between the top of Maryland and where the map features start rendering again. If I attempt to merge in Virgina it doesn't display at all.

What am I missing?

1
  • Not using SQLite, but you could use the tile-join utility from tippecanoe Commented Dec 28, 2018 at 6:41

1 Answer 1

1

The patch script will replace tiles in the destination with tiles from the source. If those tiles cover a state border, the features outside the source state in the destination state are essentially deleted from the tile. That's why you're getting the empty space above Maryland - those are the border tiles that also cover Pennsylvania and it's replacing the Pennsylvania tile instead of merging the features from both states.

To merge them you would have to take every tile in the total bounds of your coverage, select that tile from the tiles table from each overlapping state, serialize the features, merge them, and then convert and write the new BLOB to the target tile.

You should be able to just insert rows from one metadata table to the other.

0

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.