Python library for reading and writing GEMF map tile files.
Project description
GEMF
Python package for the GEMF map format. From the format specification:
This tile store format is intended to provide a static (i.e. cannot be updated without regenerating from scratch) file containing a large number of tiles, stored in a manner that makes efficient use of SD cards and with which it is easy to access individual tiles very quickly. It is intended to overcome the existing issues with the way tiles are stored in most existing Android map applications as these are not very scalable.
.gemf files may be used in mobile mapping applications like Locus
Installation
pip install gemf-map
Features
Core features are...
- reading
.gemfmap files via theGEMF.from_file()classmethod - creating a GEMF object from PNG or JPG tiles via the
GEMF.from_tiles()classmethod - writing a newly created GEMF object to file via the
write()method
Further features are...
- spatially subset (crop) a .gemf file
- extracting image tiles from binary
.gemffiles via thesave_tiles()method - adding tiles to an existing
.gemffile (TODO) - combining
GEMFobjects viastack()/+,merge()/|,intersect()/&anddifference()/-
Visualization features:
- show the tiles of a .gemf file on a
foliummap - show tile boundaries on a map
Usage
Core
from gemf import GEMF
# load an existing .gemf file
my_gemf = GEMF.from_file("MY_GEMF.gemf")
# extract the tiles
my_gemf.save_tiles("PATH/TO/TILEDIR")
# create a GEMF object from tiles on disk
new_gemf = GEMF.from_tiles("PATH/TO/TILEDIR")
# write GEMF object to .gemf file
new_gemf.write("PATH/TO/GEMF_FILE.gemf")
Lazy loading
GEMF.from_file() and GEMF.from_tiles() accept a lazy argument (default False).
With lazy=False (the default), the per-tile range details (location and size of every
tile's data) are read/computed immediately. This gives access to the full range of
features, but may take a while for files with a large number of tiles.
With lazy=True, this step is skipped. The following are available right away without
extra loading:
gemf.num_sourcesgemf.num_tilesgemf.get_zoom_levels()- inspecting
gemf.header.range_data(the per-zoom-level bounding boxes)
Any operation that needs per-tile data (e.g. save_tiles(), write(), crop(),
set_tile(), the arithmetic operators) raises DetailsNotLoadedError on a lazily loaded
GEMF. Call gemf.load_details() first to load the range details on demand:
my_gemf = GEMF.from_file("MY_GEMF.gemf", lazy=True)
# cheap, available immediately
print(my_gemf.num_tiles)
# load range details before performing per-tile operations
my_gemf.load_details()
my_gemf.save_tiles("PATH/TO/TILEDIR")
Manipulation
# crop to bounding box (all zoom levels will be cropped accordingly)
gemf_crop = my_gemf.crop(7, 60, 62, 36, 38)
Combining GEMF objects
# stack: add all sources of gemf2 onto gemf1 as new sources
combined = gemf1 + gemf2
# merge: union of tiles for sources present in both (matched by name)
# on conflicting tiles, "|" keeps gemf1's tile by default
merged = gemf1 | gemf2
# intersect: keep only tiles present in both, for shared sources
shared = gemf1 & gemf2
# difference: keep gemf1's tiles that are not present in gemf2's matching source
diff = gemf1 - gemf2
Visualization
from gemf.plot import GEMFPlot
# visualize tiles and tile boundaries
gemf_map = GEMFPlot(my_gemf)
# visualize tiles without boundaries
tile_map = GEMFPlot(my_gemf, show_tile_boundaries=False)
# visualize only boundaries (to avoid loading tile contents from disk)
boundary_map = GEMFPlot(my_gemf, show_tiles=False)
Other
# save the embedded tiles to image files
gemf_map.save_tiles("path/to/output/dir")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gemf_map-1.0.4.tar.gz.
File metadata
- Download URL: gemf_map-1.0.4.tar.gz
- Upload date:
- Size: 49.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c44d5dc7e4cff2f1360676902397c43259ffcaeeb4d14c6365ed0dc5bd23836
|
|
| MD5 |
0507317fc54aa4d74e5752d4562570b4
|
|
| BLAKE2b-256 |
30913ea10ad27518ce064f5703824f9b65c5f7661cdffbe0fa59efe9d20b8db1
|
Provenance
The following attestation bundles were made for gemf_map-1.0.4.tar.gz:
Publisher:
publish.yml on ColinMoldenhauer/GEMF
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gemf_map-1.0.4.tar.gz -
Subject digest:
3c44d5dc7e4cff2f1360676902397c43259ffcaeeb4d14c6365ed0dc5bd23836 - Sigstore transparency entry: 1818278571
- Sigstore integration time:
-
Permalink:
ColinMoldenhauer/GEMF@bfead4ce1e37fc5a0ffa68cc211c345f29e4ccfd -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/ColinMoldenhauer
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bfead4ce1e37fc5a0ffa68cc211c345f29e4ccfd -
Trigger Event:
push
-
Statement type:
File details
Details for the file gemf_map-1.0.4-py3-none-any.whl.
File metadata
- Download URL: gemf_map-1.0.4-py3-none-any.whl
- Upload date:
- Size: 50.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c6d85a7cae352c6a374ebf363b4c98bcc1040b2d3fcbfd2404305240a2ee77d
|
|
| MD5 |
3c49722ac4309c18d2fee401f6c26a13
|
|
| BLAKE2b-256 |
32b2dd395c201082bc2894c24f7bd46afbcde858672644cd1f6023b29ee961e2
|
Provenance
The following attestation bundles were made for gemf_map-1.0.4-py3-none-any.whl:
Publisher:
publish.yml on ColinMoldenhauer/GEMF
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gemf_map-1.0.4-py3-none-any.whl -
Subject digest:
2c6d85a7cae352c6a374ebf363b4c98bcc1040b2d3fcbfd2404305240a2ee77d - Sigstore transparency entry: 1818278628
- Sigstore integration time:
-
Permalink:
ColinMoldenhauer/GEMF@bfead4ce1e37fc5a0ffa68cc211c345f29e4ccfd -
Branch / Tag:
refs/tags/v1.0.4 - Owner: https://github.com/ColinMoldenhauer
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bfead4ce1e37fc5a0ffa68cc211c345f29e4ccfd -
Trigger Event:
push
-
Statement type: