Python wrapper for the libtinyhtm library.
Project description
PynyHTM
PynyHTM is a Cython based Python wrapper for libtinyhtm, the minimalistic hierarchal triangular mesh library. libtinyhtm, developed by Serge Monkewitz and Walter Landry is based on prior work from Alex Szalay, Gyorgy Fekete and Jim Gray in Searchable Sky Coverage of Astronomical Observations: Footprints and Exposures and Indexing the Sphere with the Hierarchical Triangular Mesh.
Hierarchal triangular meshes(HTM) use the sub-division of triangles, which are projected onto a sphere, to elegantly and efficiently partition the earth or the sky into regions with different identifiers.
Usage sample
The code snippets below are available in this example file.
Classes SphericalCoordinate
and V3
cover basic functionality for expressing points in 3D space.
from pynyhtm import HTM, SphericalCoordinate, Triangle, V3
# Retrieve HTM ID for a spherical coordinate
sc_1 = SphericalCoordinate(10.1234, -20.1234)
id = sc_1.get_htm_id(level=14)
print(f"HTM-ID for sc_1: {id} at level 14")
# >>> HTM-ID for sc_1: 3278525534 at level 14
# Convert spherical coordinate to vector
v_1 = sc_1.to_v3()
# Retrieve HTM ID for a V3 vector
v_2 = V3(0.1,0.2,0.3)
id = v_2.get_htm_id(level=3)
print(f"HTM-ID for v_2: {id} at level 3")
# >>> HTM-ID for v_2: 986 at level 3
# Conversion from vector to spherical coordinate
sc_2 = v_2.to_sc()
diff = sc_1.angle_separation(sc_2)
print(f"Angle between sc_1 and sc_2 (v2): {diff}")
# >>> Angle between sc_1 and sc_2 (v2): 78.05738774142326
Triangles, instantiated from the Triangle
class provide additional information about a trixel within the HTM. They contain the three vertices which make up a Trixel as well as the center and more additional information.
# Retrieve additional information about a triangle within the HTM
triangle = Triangle.from_id(id)
print(f"This triangle is in level {triangle.level}")
# >>> This triangle is in level 3
sc_center = triangle.center.to_sc()
print(f"The center is located at {sc_center}")
# >>> The center is located at SphericalCoordinate({'_latitude': 57.03662706265828, '_longitude': 59.20954536171413})
The HTM
class contains more helpers to manage HTM identifiers.
print(f"The Triangle with id {id} is located at level {HTM.get_level(id)}")
# >>> The Triangle with id 986 is located at level 3
print(f"The ID can also be expressed in it's subdivision form: {HTM.id_to_dec(id)}")
# >>> The ID can also be expressed in it's subdivision form: 23122
# Determine the children of a given triangle
children = HTM.children(id)
print(f"Children of {id}: {children}")
# >>> Children of 986: [3944, 3945, 3946, 3947]
# Determine the parent of a given id
parent = HTM.parent(id)
print(f"Parent of {id}: {parent}")
# >>> Parent of 986: 246
# Determine neighbors of a given triangle
neighbors = HTM.neighbors(id)
print(f"The neighbors of {id} are: {neighbors}")
# >>> The neighbors of 986 are: [987, 988, 1017]
# Search IDs within a circle around a given point
ids = HTM.circle_search(center=v_1, radius=0.5, level=7)
print(f"{ids} are located near center with radius 0.5")
# >>> [200104, 200105, 200106, 200107, 200108, 200134] are located near center with radius 0.5
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pynyhtm-0.0.3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3178047071bc529a28c01ce0c438c3879db4e80329d1dadb7fb7a885e6d0a31 |
|
MD5 | 3b72f814e99f1f9e09993d9f62a75932 |
|
BLAKE2b-256 | cd0b89399039d4a98df3c5c22f00b2d1cd15b7507bd5ad2606168eaf1b355fef |
Hashes for pynyhtm-0.0.3-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87c9836b643dcbeb2e7c60236d1e90dbaf6362b16af4e040fd5b12a8aed10f2d |
|
MD5 | 657a2f40d7730a601bb9eeb83a0792bb |
|
BLAKE2b-256 | 1c628aa748cac9d3514eb323286fbb3ee7a55d45c2d841ab04ae1e28528546ad |
Hashes for pynyhtm-0.0.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88b0d13eea87455ee100971ee26b54dafeaef70eeaca323463b8150608343ab1 |
|
MD5 | ab6581a11cbba94480b38956b657be02 |
|
BLAKE2b-256 | 8d6c93d15b04e1abb3a4dd2c4f7f34b2f3a1d7d6a89e1d1c1deee35752d9099d |
Hashes for pynyhtm-0.0.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e91a2554423797eb1c82e966da86fba04389240a74cb66325d441a2b43b809bf |
|
MD5 | ed267246eed4a73a566558da2ba7101a |
|
BLAKE2b-256 | 5f3233952ca2f2d07e7645fc9fb78350fcac65efe1fb4a76e5118907d67f5c52 |
Hashes for pynyhtm-0.0.3-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f6ee933500c442e2bb61a6ff92fb6d323dab4adee85233d15f1cd017ef20d7e |
|
MD5 | d0587acc9196893c80e8674fd589f697 |
|
BLAKE2b-256 | e295a4859fd412d63a8de37acf39e9aa4bdc53813cd39ff164754fc6861659d7 |
Hashes for pynyhtm-0.0.3-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c34e111e4b9a25f7771033a74fd1ff6e2f4979a89f4c0add3d59b361b7a4d825 |
|
MD5 | 0df2d013eb935b8c656fe46ec2cb44b7 |
|
BLAKE2b-256 | f630f97586c151aecab8e5e5bea01e5dbed10227a96d50168c6f9f7ffb11db48 |
Hashes for pynyhtm-0.0.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 324e30fd8a8a69ea8a1865f496ce3b2f7cb2cf6da745c8bd9c088118e6414f53 |
|
MD5 | 53cf31114bf47fc6970c39706746fe9f |
|
BLAKE2b-256 | 6b04d617f61a76b4181833bf281595b7d0a42c8ef26e08c92c7b21e30db7183c |
Hashes for pynyhtm-0.0.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 023ee3b5c3f2468f65e7666d1019576200d9fab45263f4d9ecdcfc7c2a4dc9c8 |
|
MD5 | 707855e218418f17300f37eb4664829e |
|
BLAKE2b-256 | ee3c16f535506583d9061f2a301cb12a2c83453359c336670a8a72f5742f9aed |
Hashes for pynyhtm-0.0.3-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d630572b1e8b86b2b4a8d5525770f58c60a9203dfd6f0a1ef28b5a9c1eaca85a |
|
MD5 | afcf66ad01f288e821b3854009398a81 |
|
BLAKE2b-256 | fc240ca68a4ad6518554f378e5dd2903db9249b8fd88a843ef1c66b4ceedd3e0 |
Hashes for pynyhtm-0.0.3-cp310-cp310-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 868f35aa235cfd9f51846bccf4ed4817159cb413dcedbc98d0bbc1c13b1bde9b |
|
MD5 | c5b507eb879c87ec84a80bf080ea3ecb |
|
BLAKE2b-256 | 12cf000e1399b19d9a79d9550bff867c4d059a6979c413741497aeaef1121176 |
Hashes for pynyhtm-0.0.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38fd67d99e72256c302e56a4ed490b5c7b74794b8561a58a6ee9f1d3737a6051 |
|
MD5 | 63c1a6ed2dc025e169ed849988fdf795 |
|
BLAKE2b-256 | e6b434cc23e40a77467df36bf4d4c4d1c4a8a1511e859223299b49c347a464bf |
Hashes for pynyhtm-0.0.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7533c0cc2013fe0e8fbad23cdd64249371d2eb83f4d8edd4c99ffb28941db4ae |
|
MD5 | c34a15e5eb9b060a56bcaac231da0aac |
|
BLAKE2b-256 | 9fac66695521ea5ea3f1822eb41135f1be88e0d7a529c5f8e931f0a86f20f869 |
Hashes for pynyhtm-0.0.3-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87b8e12625162e708320e46f19aa7ece6f619d3b503ac3d5ded971dc56b54ef8 |
|
MD5 | 720dafb06b2e023d559258934cd954a0 |
|
BLAKE2b-256 | 340721ed78e202ec41a7b0011ef6afccb3367132fcefbce4ec7879fc4a7e8694 |
Hashes for pynyhtm-0.0.3-cp39-cp39-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 446f604f4867337bdf5c417d45f1a59e2d71070e4042a8b849e13e74d1e6de94 |
|
MD5 | a199a018cb0831749867970e79d256f2 |
|
BLAKE2b-256 | e5c8d32f1dc6cf35ad0618b79f6b51a989fad29e9028b975e694ecffed75b04d |
Hashes for pynyhtm-0.0.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9904483404a020fcd5f04bff0a287294bad65f5aef1a0e703a025d10abf2810 |
|
MD5 | c42aa5cf627605d982458dcdecaffa69 |
|
BLAKE2b-256 | 18f46e208a5ffec4ab1f75b8252e78aaa683c33dc92d3aa114f60ee7711a6f72 |
Hashes for pynyhtm-0.0.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5740b43c5eb24d367ce4305be6405b9e98450e1e21e5ff72c4e1f491be908c2f |
|
MD5 | af228c290563a9c480923db420fc4f75 |
|
BLAKE2b-256 | 13fc9d14e80e01c2f7441db6fcce193653042bde6dc5343d2f0aec194c79cd4d |
Hashes for pynyhtm-0.0.3-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a48575be38b339b6cf9f44b4c47f63a811bef89f2f680f78d2c150b38c4cd470 |
|
MD5 | 47c4cfe090574a97cd4f70e1f3f38988 |
|
BLAKE2b-256 | 13ecb8007034f8891803ec5573f95598c8f66c1121b0f7c6e572775fbd1e9009 |
Hashes for pynyhtm-0.0.3-cp38-cp38-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 349f638a8fb280093ffb12e29ec8e1e0500e89d846c9149f00d1f09624a55539 |
|
MD5 | 2edd149dc037860f4a1caeeea2eb507d |
|
BLAKE2b-256 | d0c0efb49f07792ef7339e01ccde5e12453dc0f08373dee993d65abe257ea6f5 |
Hashes for pynyhtm-0.0.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02957841698dfc75f3e00dda180d0924a1a154c2eed3cfd5c127ca3729cfa95e |
|
MD5 | 01244c2aaefe9d83de58385d2fa7ba57 |
|
BLAKE2b-256 | 4e27949b1fd28ee51d9f0d115340de1c552d95b5e8437d4802ff8a2c6adc332b |
Hashes for pynyhtm-0.0.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b00afe00470a7cd5e4cefec98ee8e597ce1c7bbcdbc2e77d5edbff2b678c0ee4 |
|
MD5 | 12b94a7962b74b08e173d67f5fd0b7ce |
|
BLAKE2b-256 | a9e69d4fd48ab4b075dc3ffa103663c3b6c39774279a9fac0bf6c232943ff279 |