A high-performance Rust tool for processing and transforming Mapbox Vector Tiles (MVT) with advanced filtering capabilities. Apply sophisticated spatial and attribute-based filters to slim down your tiles.
For example, I'm a big fan of Protomaps' tiles generated from OpenStreetMap, but when serving tiles to Japanese customers, there are a couple things that need to be tweaked (sensitive areas, removing data that won't be shown anyways, etc..). Instead of downloading and reprocessing all the tiles from scratch, this tool takes in an already-built PMTiles archive, applies the desired filters, and outputs the filtered tiles.
MVT Wrangler reads PMTiles files (containing MVT data) and outputs filtered MBTiles databases. It provides a powerful filtering system that allows you to:
- Remove entire features based on attributes or geometry types
- Strip specific tags/properties from features
- Apply filters spatially using GeoJSON geometries
- Process tiles efficiently with parallel processing
- Spatial Filtering: Filter features based on spatial intersection with GeoJSON geometries
- Attribute Filtering: Remove features or tags based on complex expressions
- High Performance: Parallel tile processing with optimized database writes
- Flexible Expressions: Maplibre-style filter expressions for complex filtering logic
- Rust (if you don't have it, rustup is the easiest way to install)
The compiled binary will be available at target/release/mvt-wrangler.
- input: Path to the input PMTiles file
- output: Path for the output MBTiles file (will be overwritten if it exists)
- --filter / -f: Optional path to a GeoJSON filter file
The tool supports sophisticated filtering through GeoJSON filter files. See FILTERING.md for complete documentation.
Create a filter file remove-parks.geojson:
Then apply it:
- Spatial Scope: Filters only apply to features intersecting the filter geometry
- Layer Targeting: Apply different rules to different MVT layers
- Feature Removal: Drop entire features based on conditions
- Tag Stripping: Remove specific properties/tags from features
- Expression Language: Rich filtering expressions supporting:
- Comparison operators (==, !=, <, >, etc.)
- Logical operators (any, all, none, not)
- String operations (starts-with, ends-with, regex-match, regex-capture)
- Membership tests (in)
- Geometry type checks
- And much more
The tool is optimized for processing large tile sets:
- Parallel Processing: Utilizes all CPU cores for tile transformation
- Optimized Database: Uses SQLite performance pragmas for fast writes
- Memory Efficient: Streams tiles without loading entire datasets
- Progress Tracking: Real-time progress indication for long operations
The output MBTiles file follows the MBTiles specification.
This tool uses the pmtiles-rs library. When pmtiles-rs gains support for pmtiles writing, this tool will also switch to pmtiles output.
Remove unwanted features or properties from vector tiles:
Strip personally identifiable information:
Reduce tile size by removing unnecessary attributes:
- Input files must be valid PMTiles with MVT tile type
- Filter files must be valid GeoJSON FeatureCollections
This project is licensed under the MIT License. See the LICENSE file for details.