Metadata-Version: 2.4
Name: GeoPakTile
Version: 2.0.1
Summary: Create a Geopackage XYZ Tile layer.
Keywords: GIS,Geopackage,Tiles,XYZ,gpkg
Author: apwebber
Author-email: apwebber <39490780+apwebber@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE.md
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: typing-extensions>=4.0 ; python_full_version < '3.11'
Requires-Dist: morecantile>=6.2.0
Requires-Dist: numpy>=2.2.6
Requires-Dist: requests>=2.34.2
Requires-Python: >=3.10
Project-URL: Homepage, https://github.com/apwebber/GeoPakTile
Project-URL: Documentation, https://github.com/apwebber/GeoPakTile
Project-URL: Repository, https://github.com/apwebber/GeoPakTile.git
Project-URL: Issues, https://github.com/apwebber/GeoPakTile/issues
Description-Content-Type: text/markdown

# GeoPakTile

For writing geopackage XYZ raster tile layers, with support for using arbitrary grid systems.

Geopackage XYZ files can use any tile grid system, this is often defined by a server's GetCapabilities response where a TileMatrixSet defines the data co-ordinate system, the extent, the number of rows and columns in each zoom lever, and the corner co-ordinates for each zoom level. This package contains a tool for parsing the GetCapabilities XML into a [morecantile](https://github.com/developmentseed/morecantile) `TileMatrixSet`, and then for writing tiles to a new or existing geopackage.

## Examples

Write tiles to a new geopackage using web mercator (similar to mbtiles), where tiles is a list of (z, x, y, bytes). `tms` is a morecantile `TileMatrixSet` - the standard web mercator can be obtained with `morecantile.tms.get('WebMercatorQuad')`

```
# Here, a list of tiles are read from a local path, the bytes and co-ordinates are stored as tuples in a list:
# You might get these tiles from a tile server or anywhere else. Adjust accordingly.

tiles = [
    (z, x, y, path.read_bytes()),
    (z2, x2, y2, path2.read_bytes()),
    (z3, x3, y3, path3.read_bytes()),
    ...
]

with GeoPakTile(test_gpkg, tms=morecantile.tms.get('WebMercatorQuad'), mode='rwc') as gpkg:
    gpkg.add_tiles(tiles)
```

Parse a GetCapabilties xml to provide the TileMatrixSet for writing a geopackage:

```
tms_set = parse_capabilities(xml)
tms = tms_set[0] # you'll need to know which one you want, or use:

tms = get_tile_matrix_set(xml, identifier = '1km') # an identifier that you know is defined in the xml
```


### TileMatrixSet models

Tile Matrix definitions use the [morecantile](https://github.com/developmentseed/morecantile) package (`morecantile.TileMatrixSet`, `TileMatrix`, etc.) so any morecantile TileMatrixSet (built-in or custom-loaded) can be passed to `GeoPakTile`. The XML parser returns morecantile `TileMatrixSet` objects.

### XML Parser

The xml parser has been tested on NASA GetCapabilties XML and some others, if you come across any that doesn't work then please raise an issue or fix and pull request.

