srtm - 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
Prebuilt wheels are available for Python 3.12+ on Linux (x86_64, aarch64), macOS (Apple Silicon, x86_64), and Windows (x86_64).
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)
# Returns None for void data or missing tiles
elevation = service.get_elevation(35.3606, 138.7274)
if elevation is not None:
print(f"Elevation: {elevation}m") # 3776
# Interpolated query for smoother results
# Returns None if any surrounding point is void
elevation = service.get_elevation_interpolated(35.3606, 138.7274)
if elevation is not None:
print(f"Elevation: {elevation:.2f}m") # 3776.42
# Check cache performance
stats = service.cache_stats()
print(f"Cache hit rate: {stats.hit_rate:.1%}")
srtm.py Compatibility
If you're migrating from srtm.py, use rounding="floor" for exact value parity. srtm.py uses math.floor() for grid cell selection, while htg defaults to round() (true nearest-neighbor). The difference is typically 1-3 meters at grid cell boundaries.
import srtm
service = srtm.SrtmService("/path/to/srtm", cache_size=100)
# Default: true nearest-neighbor (round)
elevation = service.get_elevation(33.3448, -96.1592) # 190
# srtm.py compatible: floor-based (southwest-biased)
elevation = service.get_elevation(33.3448, -96.1592, rounding="floor") # 191
# Also works with batch queries
elevations = service.get_elevations_batch(coords, default=0, rounding="floor")
Batch Queries
Query multiple coordinates efficiently in a single call:
import srtm
service = srtm.SrtmService("/path/to/srtm", cache_size=100)
coords = [
(35.3606, 138.7274), # Mount Fuji
(27.9881, 86.9250), # Mount Everest
(46.8523, 9.1512), # Piz Bernina
]
# Returns a list of elevations; uses default (0) for void/missing data
elevations = service.get_elevations_batch(coords, default=0)
print(elevations) # [3776, 8752, 3148]
Preloading Tiles
Warm the cache at startup to avoid cold-start latency (useful when tiles are on NFS):
import srtm
service = srtm.SrtmService("/path/to/srtm", cache_size=100)
# Preload all tiles
stats = service.preload()
print(f"Loaded {stats.tiles_loaded} tiles in {stats.elapsed_ms}ms")
# Preload only CONUS + Hawaii tiles
stats = service.preload(bounds=[
(24.0, -125.0, 50.0, -66.0), # CONUS
(19.0, -161.0, 22.0, -154.0), # Hawaii
])
# Non-blocking preload (runs in background thread)
service.preload(blocking=False)
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:
Both .hgt and .hgt.zip files are supported. ZIP files are transparently extracted on first access.
Performance
srtm 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 srtm |
|---|---|---|---|---|
| srtm | Rust + PyO3 | 0.41 us | 2,419,110 q/s | 1.0x (baseline) |
| srtm.py | Pure Python (256 stars) | 1.43 us | 697,654 q/s | 3.5x slower |
| srtm4 | Python + C++ subprocess | 99,630 us | 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
Metadata
Release files for srtm 0.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| srtm-0.3.6.tar.gz | 60.8 kB | Details |
Built distributions (wheels)
Total release size: 5.2 MB
Release files / srtm-0.3.6.tar.gz
| Download URL | srtm-0.3.6.tar.gz |
|---|---|
| Size | 60.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
021ca8f09a45e094d1986916b6a53408a1faed22b0fa98a2b474eb6e1ae4391b
|
|
BLAKE2b-256 checksum How to use checksums |
10890f3532a875c2c4b356913b32b01e48a278f8d8d60be9b30af102a7a25d40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp313-cp313-win_amd64.whl
| Download URL | srtm-0.3.6-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 395.5 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6dafda346e95ca26675da3e89006e39afcb944fd28d93ca34041da8b41b5721b
|
|
BLAKE2b-256 checksum How to use checksums |
caa85db9a91761114aea191aa93ac4031b4c0dc681a78b57940db352da919b8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | srtm-0.3.6-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 572.8 kB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
ce3dfb89eecacfcff31c07ab392d32326b6a46307935eb6e43c4bce790978871
|
|
BLAKE2b-256 checksum How to use checksums |
5d4ceb1580e6eacfe49ceaf5917cbb5ea897c4be3690155c1d7bb4422c970893
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | srtm-0.3.6-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 562.5 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
a2b0185b76c9192958040002d581448a13bc764939612c0ff5ac9ef114dde6d2
|
|
BLAKE2b-256 checksum How to use checksums |
a313e95660fb093aa0717c11a2b34f51e93e0d863e3bbef30fd5796a5f05efc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | srtm-0.3.6-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 506.1 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
735012e426873da461dbdddd38e57e58b37d8352bc86afced9cd78b6e0bb0ffb
|
|
BLAKE2b-256 checksum How to use checksums |
35f95b73b0e60fd1c5dc7007033ac5f3536db300ffb8a777bda586f74e9d47e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | srtm-0.3.6-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 523.1 kB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
1594763f8056d2088ef1c857ce418544535f5aa73de3d69da23d1f9b49f4c208
|
|
BLAKE2b-256 checksum How to use checksums |
a26f0e79625ca182986aab6fd1cdfc641d4af262b14d0f1260080772256c022f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp312-cp312-win_amd64.whl
| Download URL | srtm-0.3.6-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 396.0 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
93c69275bf94101617f40e70f60bfc4cbd81e528062e01d497fcadc06ffeca0c
|
|
BLAKE2b-256 checksum How to use checksums |
656dc831345bac70d9cc7dceb337a087d37a909fbaad0e5402427ec625d7a473
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl
| Download URL | srtm-0.3.6-cp312-cp312-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 572.8 kB |
| Tags | CPython 3.12 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
bce9c46ed1d07db753322de91d75b6b4a9e89e11815b1ab7bd35aa949d223ef6
|
|
BLAKE2b-256 checksum How to use checksums |
45bc2e4e2bec3276cfa087e964d2965e23dee378c0b8b123e5e1d58ce4d5c810
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | srtm-0.3.6-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 563.0 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
9f4a46a42c7ce35c24d6f2d6ad43f11094d87a353d46ea2eaf27d140b047b28b
|
|
BLAKE2b-256 checksum How to use checksums |
a8c4898f35fa68a147ac3534004e9af174dcc96e62b9b8dad5e330bedad4b4c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | srtm-0.3.6-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 506.3 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
eb7984854934324b7a616473493c4975995c6557ba9ad09ff48fda81deb74521
|
|
BLAKE2b-256 checksum How to use checksums |
f491ff28e06561ecd6f4b6feaae6edaeb0ab5e1bf41877a84f08f3cada0c7c84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency logRelease files / srtm-0.3.6-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | srtm-0.3.6-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 523.7 kB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0e7a45e58d677a1c6672fd96f7b00970270c519921eddeafa6b5745dcbfb5494
|
|
BLAKE2b-256 checksum How to use checksums |
c34295e3e4255015c438784b1eb73261a7225fca0e3832b29708d913fd7182f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2026.
Transparency log