Skip to main content

vtpk-reader

CI Coverage Status

A library to read ESRI Vector Tile Package (.vtpk) files

Installation

pip install vtpk_reader

Getting started

Read vtpk file and extract some features

from vtpk_reader import Vtpk

vtpk = Vtpk("path/to/your/vtpk/file.vtpk")
# Get all tiles at LOD (level of detail) zero, there should only be one tiles
tiles = vtpk.get_tiles(0, None)  
# Get the one of the tiles
one_tile = list(tiles)[0]
# Extract the tile features
features = vtpk.tile_features(one_tile)
# Look at the keys in the data
print(f"{features.keys()})

More detailed example using dodge_city.vtpk

This file is can be found at by searching for "vtpk" and "dodge" on www.arcgis.com. Based on the name and the description, it probably does not contain content not available elsewhere, but being small it is a useful test file.

from vtpk_reader import Vtpk
import geopandas as gpd
import matplotlib.pyplot as plt
import contextily as cx

# Load the vtpk
vtpk = Vtpk("dodge_city.vtpk")
# Create a matplotlib plot
fig, ax = plt.subplots(figsize=(10, 10))
# Get all the tiles at the maximum Level Of Detail (LOD)
# ... not normally recommended, but in case of small VTPKs it should be OK?
tiles = vtpk.get_tiles([vtpk.max_lod], None)
# Get a color palette from matplotlib
colors = plt.rcParams['axes.prop_cycle'].by_key()['color']

for idx_tile, tile in enumerate(tiles):
  features = vtpk.tile_features(tile)

  # Plot every kind of feature there is
  for feature_key_idx, feature_key in enumerate(features.keys()):
    gdf = gpd.GeoDataFrame(
      [prop["geometry"] for prop in features[feature_key]["features"]], 
      columns=["geometry"],
      crs=vtpk.crs, 
      geometry="geometry",
    )
    gdf.plot(ax=ax, alpha=0.25, color=colors[idx_tile])

# Add a basemap
cx.add_basemap(ax, source=cx.providers.CartoDB.DarkMatter)
# Expand the plot limits by a factor
increase_factor = 0.125
xlim = ax.get_xlim() 
xextent = xlim[1] - xlim[0]
ylim = ax.get_ylim() 
yextent = ylim[1] - ylim[0]
ax.set_xlim(xlim[0] - xextent*increase_factor, xlim[1] + xextent*increase_factor/2)
ax.set_ylim(ylim[0] - yextent*increase_factor, ylim[1] + yextent*increase_factor/2)
ax.set_axis_off()

You should get something like this: logo

Metadata

Release files for vtpk-reader 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vtpk-reader 0.1.0
File Size Uploaded
vtpk_reader-0.1.0.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vtpk-reader 0.1.0
File Interpreter ABI Platform
vtpk_reader-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.5 kB

Release files / vtpk_reader-0.1.0.tar.gz

Download URL vtpk_reader-0.1.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e919dd0795923de1b4963f66e101605229aea48931b869444d34d27e70b2292c
BLAKE2b-256 checksum
How to use checksums
ac06a2c0f9d72b281f7bef83f56894def91d237b72351ae1a18e888b97081005
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / vtpk_reader-0.1.0-py3-none-any.whl

Download URL vtpk_reader-0.1.0-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06362847da268799b185f94e0d11b651de2a9032445ef4f6740058e0db0bb059
BLAKE2b-256 checksum
How to use checksums
75388cd9b67801458ff8a872463e0a48cb1f9060c65f85b09bb280840b7267d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page