FORMAT 'mvt.pmtiles'
COPY … TO · exportWrite PMTiles. Vector tiles (MVT) in a PMTiles v3 archive
-- Write two cities as a one-layer tileset (zoom 0 to 8)
COPY (SELECT 'cities' AS layer, name, population, ST_Point(lon, lat) AS geometry FROM (VALUES ('Rome', 2800000, 12.5, 41.9), ('Paris', 2100000, 2.35, 48.86)) t(name, population, lon, lat)) TO 'cities.pmtiles' (FORMAT 'mvt.pmtiles', maxzoom 8)
-- Re-tile every layer of an existing tileset into a new archive
COPY (SELECT layer, feature_id, properties, geometry FROM mvt.main.read_tiles('https://raw.githubusercontent.com/Query-farm/vgi-mvt/v0.3.1/test/fixtures/sample.pmtiles')) TO 'sample-copy.pmtiles' (FORMAT 'mvt.pmtiles', maxzoom 4, name 'sample copy')
Options
Pass these inside the COPY statement's parentheses, after FORMAT. Unknown options are rejected.
- attributionVARCHAR
- Attribution (HTML) in the metadata
- bufferDOUBLE
- Margin around each tile, in pixels of a 256-pixel tile
- descriptionVARCHAR
- Tileset description in the metadata
- extentBIGINT
- Tile coordinate grid size (units per tile edge)
- geometry_columnVARCHAR
- GEOMETRY column to encode (default: the only GEOMETRY column)
- id_columnVARCHAR
- Column of non-negative feature ids (default: a column named feature_id)
- layerVARCHAR
- Layer name for rows without a layer column (default: the file name without .pmtiles)
- layer_columnVARCHAR
- Column holding each row's layer name (default: a column named layer)
- max_tile_bytesBIGINT
- Fail if a compressed tile is larger than this (0: no limit)
- max_tilesBIGINT
- Fail if the tileset would have more tiles than this
- maxzoomBIGINT
- Highest zoom level to write
- maxzoom_columnVARCHAR
- Column giving the highest zoom each feature appears at
- minzoomBIGINT
- Lowest zoom level to write
- minzoom_columnVARCHAR
- Column giving the lowest zoom each feature appears at
- nameVARCHAR
- Tileset name in the metadata (default: the file name)
- properties_columnVARCHAR
- Column of JSON objects whose keys become attributes (default: a column named properties)
- simplifyDOUBLE
- Line and polygon simplification tolerance, in pixels of a 256-pixel tile (0 turns it off)
Full reference
Encode a query's rows as Mapbox Vector Tiles in a PMTiles archive. One row is one feature; a layer column puts rows in different layers of the same tiles, so a single COPY of a UNION ALL writes a whole multi-layer basemap.