{"library":"mapbox-vector-tile","title":"Mapbox Vector Tile","description":"Mapbox Vector Tile (MVT) is a Python library for encoding and decoding Mapbox Vector Tiles. It is currently at version 2.2.0 and receives active maintenance releases, typically addressing dependency updates and minor improvements. MVTs are an efficient format for tiled vector data, commonly used in web mapping applications for performant rendering.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install mapbox-vector-tile","pip install mapbox-vector-tile[proj]"],"cli":null},"imports":["import mapbox_vector_tile"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import mapbox_vector_tile\n\n# Example GeoJSON-like data structure for a layer\nlayer_data = {\n    \"name\": \"water\",\n    \"features\": [\n        {\n            \"geometry\": \"POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))\", # WKT geometry\n            \"properties\": {\"uid\": 123, \"foo\": \"bar\"}\n        },\n        {\n            \"geometry\": \"LINESTRING(-71.160281 42.258729,-71.160837 42.259113)\", # WKT geometry\n            \"properties\": {\"id\": 456, \"type\": \"river\"}\n        }\n    ]\n}\n\n# Encode to MVT (bytes)\nencoded_tile = mapbox_vector_tile.encode([layer_data])\nprint(f\"Encoded tile size: {len(encoded_tile)} bytes\")\n\n# Decode MVT (returns dictionary of layers)\ndecoded_layers = mapbox_vector_tile.decode(encoded_tile)\n\n# Accessing decoded data\nprint(f\"Decoded layers: {list(dec_layers.keys())}\")\nwater_layer = decoded_layers.get('water')\nif water_layer:\n    print(f\"First feature in 'water' layer: {water_layer['features'][0]['properties']}\")","lang":"python","description":"Demonstrates encoding a simple GeoJSON-like structure (using WKT geometries) into a Mapbox Vector Tile and then decoding it back. The `encode` method expects a list of layer dictionaries, each containing a name and a list of features with geometry (WKT, WKB, or Shapely object) and properties. The `decode` method returns a dictionary where keys are layer names and values are the decoded layer data.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}