PHPackages                             mostka/hgtreader - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mostka/hgtreader

Abandoned → [tito10047/hgtreader](/?search=tito10047%2Fhgtreader)Library[Utility &amp; Helpers](/categories/utility)

mostka/hgtreader
================

World elevations reader

311[1 issues](https://github.com/tito10047/hgt-reader/issues)PHPCI passing

Since May 25Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/tito10047/hgt-reader)[ Packagist](https://packagist.org/packages/mostka/hgtreader)[ RSS](/packages/mostka-hgtreader/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

HGT Elevation Reader
====================

[](#hgt-elevation-reader)

[![PHP Tests](https://github.com/tito10047/hgtreader/actions/workflows/php-tests.yml/badge.svg)](https://github.com/tito10047/hgtreader/actions/workflows/php-tests.yml)[![License](https://camo.githubusercontent.com/798509b4df525f56802b56f8096862487f08023e3d7561c68656f8dab10d0d6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4170616368652d2d322e302d626c75652e737667)](LICENSE)

Professional PHP library for reading SRTM (HGT) files with high precision and minimal memory footprint. Designed for modern PHP 8.2+ with an emphasis on SOLID principles and flexibility.

🚀 Key Features
--------------

[](#-key-features)

- **Extremely low memory footprint**: Uses `fseek` for direct data access without loading entire files into RAM.
- **High precision**: Implements bilinear interpolation for accurate elevation calculation between measurement points.
- **Flexible architecture**: Abstraction of data sources (DataSource) and tile providers (TileProvider).
- **Resolution support**: Full support for both SRTM-1 (1 arc-second) and SRTM-3 (3 arc-seconds).

📦 Installation
--------------

[](#-installation)

You can install the library via Composer:

```
composer require tito10047/hgtreader
```

🛠️ Quick Start (Modern API)
---------------------------

[](#️-quick-start-modern-api)

```
use Tito10047\HgtReader\HgtReader;
use Tito10047\HgtReader\Resolution;
use Tito10047\HgtReader\TileProvider\LocalFileSystemTileProvider;

// 1. Set the path to the folder containing .hgt files
$hgtPath = __DIR__ . '/data/hgt';

// 2. Create a tile provider (TileProvider)
$provider = new LocalFileSystemTileProvider($hgtPath);

// 3. Initialize the reader (Resolution is auto-detected from file size)
$reader = new HgtReader($provider);

// 4. Get precise elevation for coordinates
$lat = 49.38628;
$lon = 19.37702;
$elevation = $reader->getElevation($lat, $lon);

echo "Elevation: {$elevation} m";
```

🖼️ Purpose and Usage
--------------------

[](#️-purpose-and-usage)

The library is ideal for generating elevation profiles of tracks, terrain analysis, or visualizing geographical data.

[![Elevation profile 1](example2.png)](example2.png)*Example of track elevation profile rendering.*

[![Elevation profile 2](example.png)](example.png)*Detailed visualization of terrain changes.*

🧩 Advanced Features
-------------------

[](#-advanced-features)

### Custom DataSources

[](#custom-datasources)

If you need to read data from memory (e.g., during network transfers), you can use `MemoryDataSource`:

```
use Tito10047\HgtReader\DataSource\MemoryDataSource;
// ...
$content = file_get_contents('path/to/file.hgt');
$dataSource = new MemoryDataSource($content);
```

### SRTM-1 Support

[](#srtm-1-support)

For more detailed data (3601x3601 points), simply change the resolution:

```
$reader = new HgtReader($provider, Resolution::Arc1);
```

👴 Legacy Support (Backward Compatibility)
-----------------------------------------

[](#-legacy-support-backward-compatibility)

The original static interface is available for existing projects:

```
// The old way of calling is still functional via a wrapper
HgtReader::init(__DIR__ . '/data/hgt', 3); // 3 for SRTM-3
$elevation = HgtReader::getElevation(49.38, 19.37);
```

📂 Where to download HGT data?
-----------------------------

[](#-where-to-download-hgt-data)

You can obtain data in .hgt format from various sources, for example:

- [Viewfinder Panoramas](http://www.viewfinderpanoramas.org/Coverage%20map%20viewfinderpanoramas_org3.htm)
- [NASA Earthdata (SRTM)](https://earthdata.nasa.gov/)

🧪 Testing
---------

[](#-testing)

The project is fully covered by tests using PHPUnit:

```
./vendor/bin/phpunit tests
```

📄 License
---------

[](#-license)

This project is licensed under the Apache-2.0 License - see the `LICENSE` file for details.

---

Author: [Jozef Môstka](mailto:jozef@mostka.com)

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance47

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11459248?v=4)[Jozef Môstka](/maintainers/tito10047)[@tito10047](https://github.com/tito10047)

---

Top Contributors

[![tito10047](https://avatars.githubusercontent.com/u/11459248?v=4)](https://github.com/tito10047 "tito10047 (21 commits)")

---

Tags

elevation-apielevation-dataphp

### Embed Badge

![Health badge](/badges/mostka-hgtreader/health.svg)

```
[![Health](https://phpackages.com/badges/mostka-hgtreader/health.svg)](https://phpackages.com/packages/mostka-hgtreader)
```

###  Alternatives

[markrogoyski/itertools-php

Iteration tools for PHP

14912.2k](/packages/markrogoyski-itertools-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
