Skip to content

muety/pyquadkey2

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

83 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌍 pyquadkey2

Documentation

This is a feature-rich Python implementation of QuadKeys, an approach to geographical tiling, popularized by Microsoft to be used for Bing Maps.

In essence, the concept is to recursively divide the flat, two-dimensional world map into squares. Each square contains four squares as children, which again contain four squares and so on, up centimeter-level precision. Each of these squares is uniquely identifiable with a string like 021030032.

For more details on the concept, please refer to the original article.

muety/pyquadkey2 originates from a fork of buckhx/QuadKey, which is not maintained anymore. It builds on top of that project and adds:

  • βœ… Several (critical) bug fixes
  • βœ… Python 3 support
  • βœ… Type hints for all methods
  • βœ… Higher test coverage
  • βœ… Cython backend for improved performance
  • βœ… 64-bit integer representation of QuadKeys
  • βœ… Additional features and convenience methods

Please note: This library is still in development and not considered 100 % stable. You may want to consider mercantile as an alternative (pure Python) implementation of QuadKeys. Also check What the Tile?.

Installation

Requirements

This library requires Python 3.10 or higher. To compile it from source, Cython is required in addition.

Using Pip

$ pip install pyquadkey2

Pip installation is only tested for Linux and Mac, yet. If you encounter problems with the installation on Windows, please report them as a new issue.

From archive

$ wget https://github.com/muety/pyquadkey2/releases/download/0.3.3/pyquadkey2-0.3.3.tar.gz
$ pip install pyquadkey2-0.3.3.tar.gz

From source

Prerequisites (Linux)

  • gcc
    • Fedora: dnf install @development-tools
    • Ubuntu / Debian: apt install build-essential
  • python3-devel
    • Fedora: dnf install python3-devel
    • Ubuntu / Debian: apt install python3-dev
    • Others: See here

Prerequisites (Windows)

  • Visual C++ Build Tools 2015 (with Windows 10 SDK) (see here)

Build

# Check out repo
$ git clone https://github.com/muety/pyquadkey2

# Create and active virtual environment (optional)
$ python -m venv ./venv
$ source venv/bin/activate

# Install dependencies and run the build
$ pip install build
$ python -m build

Developer Notes

Unit Tests

# Use env PYTHONPATH=./src as a option to choose test on src or test on installed package
PYTHONPATH=./src python3 -m unittest -v tests/test_*.py tests/*/test_*.py

# Or use pytest to make your life easier
pytest

Release

See here.

cd dist
twine upload --repository testpypi *

License

Apache 2.0

Buy me a coffee