High-performance SRTM elevation data library
Project description
htg - High-performance SRTM Elevation Library
Ultra-fast SRTM elevation queries in Python. Built with Rust, delivering 3.5x faster performance than the most popular Python SRTM library.
Python bindings for the htg Rust library, providing blazingly fast elevation queries from SRTM .hgt files with sub-microsecond latency.
Installation
pip install srtm
Quick Start
import srtm
# Create service with up to 100 cached tiles
service = srtm.SrtmService("/path/to/srtm", cache_size=100)
# Query elevation (Mount Fuji)
elevation = service.get_elevation(35.3606, 138.7274)
print(f"Elevation: {elevation}m") # 3776
# Interpolated query for smoother results
elevation = service.get_elevation_interpolated(35.3606, 138.7274)
print(f"Elevation: {elevation:.2f}m") # 3776.42
# Check cache performance
stats = service.cache_stats()
print(f"Cache hit rate: {stats.hit_rate:.1%}")
Utility Functions
import srtm
# Convert coordinates to filename
filename = srtm.lat_lon_to_filename(35.5, 138.7)
print(filename) # "N35E138.hgt"
# Parse filename to coordinates
coords = srtm.filename_to_lat_lon("N35E138.hgt")
print(coords) # (35, 138)
# Void value constant
print(srtm.VOID_VALUE) # -32768
SRTM Data
Download SRTM .hgt files from:
Performance
htg-python delivers exceptional performance through its Rust core and PyO3 bindings, significantly outperforming traditional Python SRTM libraries.
Benchmarks vs Popular Python Libraries
Comparison using local .hgt files only (fair, apples-to-apples test):
| Library | Implementation | Per Query | Throughput | vs htg-python |
|---|---|---|---|---|
| htg-python | Rust + PyO3 | 0.41 μs | 2,419,110 q/s | 1.0x (baseline) ⚡ |
| srtm.py | Pure Python (256 ⭐) | 1.43 μs | 697,654 q/s | 3.5x slower |
| srtm4 | Python + C++ subprocess | 99,630 μs | 10 q/s | 241,017x slower |
Key findings:
- 3.5x faster than srtm.py (most popular, fair comparison)
- 241,000x faster than srtm4 (subprocess overhead dominates)
- Sub-microsecond latency - queries complete in 0.41 microseconds
- 2.4 million queries/second on a single thread
Benchmark environment: Python 3.12, macOS (Apple Silicon). See BENCHMARKS.md for full methodology.
Why So Fast?
- Zero-copy memory access: Memory-mapped I/O eliminates data copying
- No subprocess overhead: Direct Rust function calls via PyO3 (unlike srtm4's subprocess approach)
- Optimized compilation: LLVM optimizations with inline expansion
- Efficient caching: In-memory LRU cache vs disk-based caching
Real-World Performance
import srtm
service = srtm.SrtmService("/path/to/data", cache_size=100)
# Single query: ~0.4 microseconds (sub-millisecond!)
elevation = service.get_elevation(35.3606, 138.7274)
# Batch queries: ~147k per second on a single thread
for lat, lon in coordinates:
elevation = service.get_elevation(lat, lon)
Production-ready: Can handle millions of requests per second with multiple cores.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 srtm-0.3.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: srtm-0.3.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 371.1 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a092ddb6ec3e9d88d3986aca0111497e078f3842d7a02dddd7d103f205ab175
|
|
| MD5 |
91001d27d5ac73cca13ad7c427451bec
|
|
| BLAKE2b-256 |
0f717ff5cbd1cf0ecb2e1cd18f9e3f1c8750c2babae59705565295cd76fec47d
|
Provenance
The following attestation bundles were made for srtm-0.3.0-cp312-cp312-win_amd64.whl:
Publisher:
release.yml on pedrosanzmtz/htg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
srtm-0.3.0-cp312-cp312-win_amd64.whl -
Subject digest:
9a092ddb6ec3e9d88d3986aca0111497e078f3842d7a02dddd7d103f205ab175 - Sigstore transparency entry: 953343824
- Sigstore integration time:
-
Permalink:
pedrosanzmtz/htg@2048bc5acdf595d4f6f404ad2f87ccb1aabbbe93 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pedrosanzmtz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2048bc5acdf595d4f6f404ad2f87ccb1aabbbe93 -
Trigger Event:
push
-
Statement type:
File details
Details for the file srtm-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl.
File metadata
- Download URL: srtm-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl
- Upload date:
- Size: 536.0 kB
- Tags: CPython 3.12, manylinux: glibc 2.34+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0332cb8e87632fe1e88d1e5d9e2fa551ffd487f1552dcd9a84b4efe2206c3130
|
|
| MD5 |
cec209922caf28d4ac5ed2c2f55db353
|
|
| BLAKE2b-256 |
833ff29416bf900207153903e2d42c62dd9ca263c132392aac1128e90e6db8d7
|
Provenance
The following attestation bundles were made for srtm-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl:
Publisher:
release.yml on pedrosanzmtz/htg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
srtm-0.3.0-cp312-cp312-manylinux_2_34_x86_64.whl -
Subject digest:
0332cb8e87632fe1e88d1e5d9e2fa551ffd487f1552dcd9a84b4efe2206c3130 - Sigstore transparency entry: 953343815
- Sigstore integration time:
-
Permalink:
pedrosanzmtz/htg@2048bc5acdf595d4f6f404ad2f87ccb1aabbbe93 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pedrosanzmtz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2048bc5acdf595d4f6f404ad2f87ccb1aabbbe93 -
Trigger Event:
push
-
Statement type:
File details
Details for the file srtm-0.3.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: srtm-0.3.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 475.1 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5a3ed807c387d3cfeca1f5e3860baae19e51d96ed8fbb1db8e60994607874c3
|
|
| MD5 |
123399d59bf920a576e57c5427b62240
|
|
| BLAKE2b-256 |
6837a4ce0fc16f7b299ddd8a2cac15d7b49e3db854b7e7365c33898f109784c5
|
Provenance
The following attestation bundles were made for srtm-0.3.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
release.yml on pedrosanzmtz/htg
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
srtm-0.3.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
c5a3ed807c387d3cfeca1f5e3860baae19e51d96ed8fbb1db8e60994607874c3 - Sigstore transparency entry: 953343825
- Sigstore integration time:
-
Permalink:
pedrosanzmtz/htg@2048bc5acdf595d4f6f404ad2f87ccb1aabbbe93 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/pedrosanzmtz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2048bc5acdf595d4f6f404ad2f87ccb1aabbbe93 -
Trigger Event:
push
-
Statement type: