Skip to content

Conversation

@spwoodcock
Copy link

@spwoodcock spwoodcock commented Oct 23, 2025

Rationale

Why do we need this?

  • It's easy enough for developers to use go-pmtiles, sure.
  • But it's intimidating for many end users to use a CLI.
  • QGIS is still reasonably advanced for the users I tend to work with, but it's a nice middle-ground. Many people can use QGIS.
  • QGIS provides a really nice util to generate MBTiles from the canvas extent / layers.
  • But there is no easy pathway from there to convert to PMTiles for users than need them (for example someone creating a project for QField mapping).

State of PMTiles in QGIS

Explained in the README.md, but I will the content below:

  • GDAL can't handle raster PMTiles as of yet (last checked 23/10/2025).
  • As a consequence QGIS does not have support for reading or writing
    raster PMTile files.
  • This plugin is an interim solution to convert MBTiles file into PMTiles, using the official Python package.
  • It bundles a vendored pmtiles Python package inside the plugin.

Testing ogr2ogr & GDAL

ogr2ogr -if "MBTiles" info ./myfile.mbtiles --debug on

# Results in:
# SQLite: 1 features read on layer 'SELECT'.
# SQLite: 8 features read on layer 'SELECT'.
# MBTiles: This files contain raster tiles, but driver open in vector-only mode
# ERROR 1: Unable to open datasource `./bing_basemap.mbtiles' with the following drivers.

# Can't read mbtiles, so no pmtiles conversion
gdal convert --input myfile.mbtiles --output myfile.pmtiles --output-format "PMTiles"

# Results in:
# ERROR 1: convert: Invalid value for argument 'output-format'. Driver 'PMTiles' does not expose the required 'DCAP_RASTER' capability.

Options available

  • Tippecanoe (too heavy to bundle in QGIS / may cause licensing issues).
  • go-pmtiles (hard to bundle different OS binaries in a plugin).
  • Direct Python library usage (this plugin).

![NOTE]
The go-pmtiles binary is much more efficient than the Python library.

If we find an elegant solution for bundling the binary inside the
QGIS Plugin, that could be considered too.
Note the status of the gopy project isn't looking great though.
The CGO requirement of go-pmtiles makes this OS specific and tricky to solve.

Alternatively, I assume the C++ code in this repo could be used
to make a C++ plugin for QGIS too.

This PR

  • Includes a small QGIS plugin for conversion from MBTiles --> PMTiles.

  • Functionality could be expanded in future, but this is a first PoC:

    image
  • This repo seemed like a logical place to house this code, but let me know if it should just go in a separate repo.

  • I plan to publish the plugin on the QGIS plugin repository. https://plugins.qgis.org/plugins/PMTiles/

Any feedback welcomed! 😄


Note I ended up making PR #599 in the process of writing this plugin. As an MBTiles file a user had given me did not have the center metadata.


Note 2: maybe I got a bit ahead of myself putting this in the PMTiles repo, with the protomaps logo on the plugin. Sorry if that causes any issues! I'm very happy to cede ownership of the plugin and any references to myself to Protomaps, or publish this elsewhere under my name instead. Let me know what works best!


Note 3: final note to say, I full expect this plugin will be dropped and no longer maintained once PMTiles support is improved in GDAL (raster) and QGIS (read / write), to allow conversion from MBTiles --> PMTiles directly in QGIS.

@spwoodcock spwoodcock force-pushed the feat/qgis-mbtile-pmtile-convert-plugin branch 2 times, most recently from 9a44801 to cf47566 Compare October 23, 2025 19:03
@spwoodcock spwoodcock force-pushed the feat/qgis-mbtile-pmtile-convert-plugin branch from cf47566 to e2457a6 Compare October 23, 2025 19:05
@bdon
Copy link
Member

bdon commented Oct 24, 2025

Thanks for creating this! Can you maintain this in a repository under your own account?

I will add some comments inline

@spwoodcock
Copy link
Author

No problem at all - I'll be happy to do that!

I might put it under the hotosm org instead then 😃

It would be good to have a logo, but nothing springs to mind right now! I'll also have a think

spwoodcock added a commit to hotosm/qgis-pmtiles that referenced this pull request Nov 20, 2025
@spwoodcock
Copy link
Author

Moved to new repo: https://github.com/hotosm/qgis-pmtiles/blob/main/README.md

Closing 👍

@spwoodcock spwoodcock closed this Nov 20, 2025
@spwoodcock spwoodcock deleted the feat/qgis-mbtile-pmtile-convert-plugin branch November 20, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants