Skip to main content

srtm-rs - High-performance SRTM Elevation Library

PyPI License: MIT

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-rs

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_rs

# Create service with up to 100 cached tiles
service = srtm_rs.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_rs

service = srtm_rs.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_rs

service = srtm_rs.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_rs

service = srtm_rs.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_rs

# Convert coordinates to filename
filename = srtm_rs.lat_lon_to_filename(35.5, 138.7)
print(filename)  # "N35E138.hgt"

# Parse filename to coordinates
coords = srtm_rs.filename_to_lat_lon("N35E138.hgt")
print(coords)  # (35, 138)

# Void value constant
print(srtm_rs.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-rs 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-rs
srtm-rs 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_rs
service = srtm_rs.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-rs 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for srtm-rs 0.4.0
File Size Uploaded
srtm_rs-0.4.0.tar.gz 63.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for srtm-rs 0.4.0
File
srtm_rs-0.4.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
srtm_rs-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.34+ x86-64 Details
srtm_rs-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ ARM64 Details
srtm_rs-0.4.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
srtm_rs-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.12+ x86-64 Details
srtm_rs-0.4.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
srtm_rs-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.34+ x86-64 Details
srtm_rs-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ ARM64 Details
srtm_rs-0.4.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
srtm_rs-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.12+ x86-64 Details

Total release size: 4.5 MB

Release files / srtm_rs-0.4.0.tar.gz

Download URL srtm_rs-0.4.0.tar.gz
Size 63.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e4c90ff56985f7574f9c0251db1fc4a7169d21573f217ba692f05c97ab2170a9
BLAKE2b-256 checksum
How to use checksums
1a88e2221732ba3cb32513d4a9d366dad525733da988c3bb06f99d213565a81f
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp313-cp313-win_amd64.whl

Download URL srtm_rs-0.4.0-cp313-cp313-win_amd64.whl
Size 376.0 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
ffbcd68e8e81f6fb5be97189593efd4653817a1858ff5f5adf5cd64b241605b9
BLAKE2b-256 checksum
How to use checksums
e9e8ce29a068c724d7f36ac478ef796382f54844f67d209d14e4b6e59a5b5d8b
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl

Download URL srtm_rs-0.4.0-cp313-cp313-manylinux_2_34_x86_64.whl
Size 484.6 kB
Tags CPython 3.13 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
8d802e552098da4194f5a1a9e378edcdce1d3bb30061f3e785203a4735dfc9b0
BLAKE2b-256 checksum
How to use checksums
3b5e2a722599193b3958ed3e7ac23a98f41fc5bfc5693d74035e2c9422b1d7e6
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL srtm_rs-0.4.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 473.7 kB
Tags CPython 3.13 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
aa8b3d73fc8361df0cafab7318c3242ea18a66db5e6947796fdb9f5aa8a53368
BLAKE2b-256 checksum
How to use checksums
e89f8841ea07895f1cb16ed828af6d6e32f2d297b793397150b9653238647f87
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL srtm_rs-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Size 439.0 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9455985961bb724acd8814fc2a079bfe6d0090a78c16855569309d72697e8d9b
BLAKE2b-256 checksum
How to use checksums
360da29c0627f08faa6d0e2649c64a343662c1c89fdee673a1a4e1126c0956e5
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl

Download URL srtm_rs-0.4.0-cp313-cp313-macosx_10_12_x86_64.whl
Size 460.1 kB
Tags CPython 3.13 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
e674ca60f897072b6bee382b17828ee88978df1d44fa5c5f1e7373eacc6c7ad0
BLAKE2b-256 checksum
How to use checksums
7fe80bee1f36a5563dd32b55513e5fc5378a76fac6c38f1564d3c912ff4125bc
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp312-cp312-win_amd64.whl

Download URL srtm_rs-0.4.0-cp312-cp312-win_amd64.whl
Size 376.2 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
e55b9c0c504086be746baa39954af1ade6379734baef9edbe7729a6350a11e5d
BLAKE2b-256 checksum
How to use checksums
5885d5e84eee4857f9429f5bc36e5810f11e924c8a19f89d53c7f325a37e7cd1
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl

Download URL srtm_rs-0.4.0-cp312-cp312-manylinux_2_34_x86_64.whl
Size 485.3 kB
Tags CPython 3.12 Linux glibc 2.34+ x86-64
SHA-256 checksum
How to use checksums
60a4c21bb8acd50368012522a5782e4c5044007dd775ff0bf85279198b26887d
BLAKE2b-256 checksum
How to use checksums
aedb50e9426cf1e3082c25cfdfa0ce9b40eb90e215565c35b6ca72256925d35c
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL srtm_rs-0.4.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 474.3 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64
SHA-256 checksum
How to use checksums
d5e734881f98ff81e4b699b88470cc0100a38aca982304d26ffa7826350e0bb6
BLAKE2b-256 checksum
How to use checksums
e1184b4392bfebbd283dded62c4d283ed628d4e61487456914ae224cd3456df7
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL srtm_rs-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Size 439.5 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
622e3e3f0987ada879e6346f5b83ac234f7d2c403bf0059b6eaa108d8aabd968
BLAKE2b-256 checksum
How to use checksums
3dcad5cdcdeb86c129d2e4a54f005d99be1f300e6d6e29b872099ac188098388
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 Mar 21, 2026.

Transparency log

Release files / srtm_rs-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl

Download URL srtm_rs-0.4.0-cp312-cp312-macosx_10_12_x86_64.whl
Size 461.0 kB
Tags CPython 3.12 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
d8c3cb96195e48782fdec2fca2787608fcefc0ad6227364070ae0f33edfeefd2
BLAKE2b-256 checksum
How to use checksums
a53b2197b9143a123d7642d632fd420dae8099f8493af47b73fd94242ef08ce5
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 Mar 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

11 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page