Skip to main content

GmAlt HGT file parser

https://travis-ci.org/gmalt/hgtparser.svg?branch=master

Introduction

This package provides a class to parse and iterate over HGT file. It should support SRTM1 and SRTM3 formats but I must confess having only worked with SRTM3 for now.

Installation

pip install gmalthgtparser

This is compatible python 2.7, 3.4, 3.5 and 3.6.

Usage

Import the parser :

>>> from gmalthgtparser import HgtParser

Get the elevation of a coordinate inside a file

>>> with HgtParser('/tmp/N00E010.hgt') as parser:
...    alt = parser.get_elevation((1.0001, 10.0001))  # (alt, lng)
...    # return a tuple (line index from the top, column index from the left, elevation in meters)
...    print(alt)
...
(0, 0, 57)

Iterate over all the elevation values inside a file.

>>> with HgtParser('/tmp/N00E010.hgt') as parser:
...    for elev_value in parser.get_value_iterator():
...        # each value is a tuple (zero based line number, zero based column number, zero based index, square corners of the elevation value, elevation value)
...        print(elev_value)
...        break
...
(0, 0, 0, ((0.9995833333333334, 9.999583333333334), (1.0004166666666667, 9.999583333333334), (1.0004166666666667, 10.000416666666666), (0.9995833333333334, 10.000416666666666)), 57)

Iterate over square of elevation values inside a file.

>>> with HgtParser('/tmp/N00E010.hgt') as parser:
...    for elev_value in parser.get_sample_iterator(50, 50):  # (width, height)
...        # each value is a tuple (zero based line number of top left corner, zero based column number of top left corner, zero based index of top left corner, square corners position, list of all elevation values in square line per line)
...        print(elev_value[:-1])
...        # print number of lines in elevation values list and number of column in each line and the first elevation value
...        print(len(elev_value[4]), len(elev_value[4][0]), elev_value[4][0][0])
...        break
...
(0, 0, 0, (0.95875, 9.999583333333334), (1.0004166666666667, 9.999583333333334), (1.0004166666666667, 10.04125), (0.95875, 10.04125))
(50, 50, 57)

Release

Just for me to remember

# Increase version number and tag repository
rm -rf gmalthgtparser.egg-info/
python setup.py register -r pypitest
python setup.py sdist bdist_egg bdist_wheel upload -r pypitest
# check installation in a custom venv
mkdir tmp
cd tmp
virtualenv venv
. venv/bin/activate
pip install -i https://testpypi.python.org/pypi gmalthgtparser
python
from gmalthgtparser import HgtParser
# Then push to production
python setup.py register -r pypi
python setup.py sdist bdist_egg bdist_wheel upload -r pypi

Metadata

Release files for gmalthgtparser 1.1.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 gmalthgtparser 1.1.0
File Size Uploaded Provenance Actions
gmalthgtparser-1.1.0.tar.gz 7.3 kB Without provenance Details for gmalthgtparser-1.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for gmalthgtparser 1.1.0
File Interpreter ABI Platform Actions
gmalthgtparser-1.1.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for gmalthgtparser-1.1.0-py2.py3-none-any.whl
gmalthgtparser-1.1.0-py2.7.egg Legacy Egg format - - Details for gmalthgtparser-1.1.0-py2.7.egg

Total release size: 27.6 kB

Release files / gmalthgtparser-1.1.0.tar.gz

Download URL gmalthgtparser-1.1.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5eee11cd0096fd5e5aceaefc785b994446752b6ff0bbb049ce95e2a422c0fd79
BLAKE2b-256 checksum
How to use checksums
1500e742396a1bf129dd0e44d0e1f83c1aeb688e0cc1ecd4f0a810a3a578ef74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / gmalthgtparser-1.1.0-py2.py3-none-any.whl

Download URL gmalthgtparser-1.1.0-py2.py3-none-any.whl
Size 8.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
351db8e6d1e94820be27c7bf27f9d91f1d8607795456d134734d962df88f91ab
BLAKE2b-256 checksum
How to use checksums
a776d60bf0ae8b4b2c0fb62bf900e91020ced9aa0a7158f5215806a230322dd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / gmalthgtparser-1.1.0-py2.7.egg

Download URL gmalthgtparser-1.1.0-py2.7.egg
Size 12.0 kB
Tags Egg
SHA-256 checksum
How to use checksums
95caabd4030b6986acd78cd133a694ac45314fa5d529e7043ab05693c95ab5fe
BLAKE2b-256 checksum
How to use checksums
dff2d87aba695574d0c50f20c4ea916aa846fb9c97c3066b416e38b6657014f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for gmalthgtparser 1.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

3 release files No provenance

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