Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c135ea7

Browse files
committed
Releasing version 0.4.0
1 parent 3bc0eb2 commit c135ea7

File tree

7 files changed

+622
-383
lines changed

7 files changed

+622
-383
lines changed

experiments_to_tiff.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import gdal
2+
import numpy
3+
import pickle
4+
5+
6+
with open("can_be_seen_counts.pickle", "rb") as f:
7+
data = pickle.load(f)
8+
9+
rows = 1201
10+
cols = 1201
11+
base_lat = 40.064531
12+
base_long = -7.462507
13+
14+
with open("can_be_seen_counts.asc", "w") as f:
15+
f.write(f"ncols {cols}\n")
16+
f.write(f"nrows {rows}\n")
17+
f.write(f"xllcorner {base_long}\n")
18+
f.write(f"yllcorner {base_lat}\n")
19+
f.write(f"cellsize {1/1200}\n")
20+
f.write(f"NODATA_value {-1}")
21+
for n, v in enumerate(data.values()):
22+
if n % 1201 == 0:
23+
f.write("\n")
24+
else:
25+
f.write(" ")
26+
f.write(str(v))
27+

haversine_profile.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import cProfile
2+
3+
from srtm.utilities import haversine
4+
5+
def do_it():
6+
for _ in range(1, 1000000):
7+
haversine(1.23456, 2.23456, 3.23456, 4.23456)
8+
9+
cProfile.run('do_it()', filename='haversine.cprof')
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
Metadata-Version: 2.1
2+
Name: python-srtm
3+
Version: 0.2.0
4+
Summary:
5+
Home-page: https://github.com/adamcharnock/python-srtm
6+
License: MIT
7+
Keywords: nasa,geospatial,altitude,elevation-profile
8+
Author: Adam Charnock
9+
Author-email: [email protected]
10+
Requires-Python: >=3.8,<4.0
11+
Classifier: License :: OSI Approved :: MIT License
12+
Classifier: Programming Language :: Python :: 3
13+
Classifier: Programming Language :: Python :: 3.8
14+
Project-URL: Repository, https://github.com/adamcharnock/python-srtm
15+
Description-Content-Type: text/markdown
16+
17+
# NASA SRTM altitude data parsing in Python
18+
19+
Provides an API onto SRTM `.hgt` or `.hgt.zip` files.
20+
21+
Requires Python 3.8, **may** work with Python 3.6 & 3.7.
22+
23+
## Installation
24+
25+
```
26+
pip install python-srtm
27+
28+
export SRTM1_DIR=/path/to/srtm1/
29+
export SRTM3_DIR=/path/to/srtm3/
30+
```
31+
32+
## Use
33+
34+
You can access either SRTM1 or SRTM3 data. SRTM 1, for example:
35+
36+
```python
37+
# SRTM1 - 30m resolution
38+
>>> from srtm import Srtm1HeightMapCollection
39+
>>> srtm1_data = Srtm1HeightMapCollection()
40+
>>> srtm1_data.get_altitude(latitude=40.123, longitude=-7.456)
41+
615
42+
>>> Srtm1HeightMapCollection().get_elevation_profile(40.123, -7.456, 40.129, -7.460)
43+
[615, 620, 618, 620, 616, 603, 593, 582, 575, 579, 580, 589, 589, 581, 565, 553, 545, 541, 534, 533, 529, 520, 514]
44+
```
45+
46+
Or SRTM3:
47+
48+
```python
49+
# SRTM3 - 90m resolution
50+
>>> from srtm import Srtm3HeightMapCollection
51+
>>> srtm3_data = Srtm3HeightMapCollection()
52+
>>> srtm3_data.get_altitude(latitude=40.123, longitude=-7.456)
53+
608
54+
>>> Srtm3HeightMapCollection().get_elevation_profile(40.123, -7.456, 40.129, -7.460)
55+
[626, 616, 585, 593, 577, 548, 528, 514]
56+
```
57+
58+
## Profiling
59+
60+
```python
61+
import cProfile
62+
cProfile.run('function_to_profile()', filename='output.cprof')
63+
```
64+
65+
```bash
66+
brew install qcachegrind
67+
pip install pyprof2calltree
68+
pyprof2calltree -k -i /pythonprofiling/profiler/first_iteration.cprof
69+
```
70+
71+
## Release process
72+
73+
For internal reference:
74+
75+
```
76+
# Run the tests
77+
pytest
78+
79+
# Update the setup.py
80+
dephell convert
81+
black setup.py
82+
83+
# Ensure poetry.lock is up to date
84+
poetry lock
85+
86+
export VERSION="VERSION HERE"
87+
88+
# Version bump
89+
poetry version $VERSION
90+
91+
92+
# Commit
93+
git add .
94+
git commit -m "Releasing version $VERSION"
95+
96+
# Tagging and branching
97+
git tag "v$VERSION"
98+
git branch "v$VERSION"
99+
git push origin \
100+
refs/tags/"v$VERSION" \
101+
refs/heads/"v$VERSION" \
102+
master
103+
104+
poetry publish --build
105+
```
106+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Wheel-Version: 1.0
2+
Generator: poetry 1.0.5
3+
Root-Is-Purelib: true
4+
Tag: py3-none-any

0 commit comments

Comments
 (0)