summaryrefslogtreecommitdiff
path: root/python-topocalc.spec
blob: df61043546d8c5bef71964d5dc02531e397c51c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
%global _empty_manifest_terminate_build 0
Name:		python-topocalc
Version:	0.5.0
Release:	1
Summary:	Topo calculations like gradient and sky view
License:	CC0 1.0
URL:		https://github.com/USDA-ARS-NWRC/topocalc
Source0:	https://mirrors.aliyun.com/pypi/web/packages/53/d4/06d34bc7f7cb67d499d790275cd6f00472a5f5d2bd07d7e37ce7b6973aea/topocalc-0.5.0.tar.gz
BuildArch:	noarch

Requires:	python3-numpy
Requires:	python3-Click
Requires:	python3-spatialnc
Requires:	python3-setuptools-scm

%description
# topocalc

[![Pypi version](https://img.shields.io/pypi/v/topocalc.svg)](https://pypi.python.org/pypi/topocalc)
[![Coverage Status](https://coveralls.io/repos/github/USDA-ARS-NWRC/topocalc/badge.svg?branch=main)](https://coveralls.io/github/USDA-ARS-NWRC/topocalc?branch=main)
[![Maintainability](https://api.codeclimate.com/v1/badges/20930fef2e7b7fe91dd3/maintainability)](https://codeclimate.com/github/USDA-ARS-NWRC/topocalc/maintainability)

The `topocalc` package is a collection of functions to calculate various metrics on a digital elevation model (DEM). The calculations follow the equations laid out in [Dozier and Frew, 1990](https://doi.org/10.1109/36.58986) for the gradient, horizon and sky view factor. Currently the supported calculations are:

1. Gradient for slope and aspect
2. Horizon angles for an azimuth
3. Sky view factor for percent of the sky that is visible from a point on the DEM

- [topocalc](#topocalc)
- [Background](#background)
  - [Azimuth convention](#azimuth-convention)
  - [Gradient for slope and aspect](#gradient-for-slope-and-aspect)
  - [Horizon angles](#horizon-angles)
  - [Sky view factor](#sky-view-factor)
- [Usage](#usage)
  - [Installation](#installation)
  - [Gradient usage](#gradient-usage)
  - [Sky view factor usage](#sky-view-factor-usage)
  - [Command Line Interface](#command-line-interface)

# Background

## Azimuth convention

For the azimuth's and aspects, the convention is that South is 0 degrees (0 radians) with positive values to the East (+90 degrees or pi/4 radians) and negative values to the West (-90 degrees or -pi/4 radians). North is -180 degrees or -pi/2.

## Gradient for slope and aspect

The gradient method calculates the slope and aspect of the input DEM. There are two methods in `topocalc.gradient` the `gradient_d4` and `gradient_d8`.

`gradient_d4` mimics the slope and aspect calculations of the [IPW `gradient`](https://github.com/USDA-ARS-NWRC/ipw/tree/main/src/bin/topocalc/gradient) function. This calculates the slope for a finite difference in just the x/y direction.

`gradient_d8` (the default) uses a second order finite difference for a 3x3 square around a given point on the DEM.

The gradient is used to calculate the aspect from North (0 degrees). A conversion function will take the aspect in degrees and convert to radians with South being 0.

## Horizon angles

The horizon angle for a point on the DEM is the angle from zenith to the horizon for a given azimuth. Following the methods laid out in [Dozier and Frew, 1990](https://doi.org/10.1109/36.58986) and in [IPW `horizon`](https://github.com/USDA-ARS-NWRC/ipw/tree/main/src/bin/topocalc/horizon) the grid is rotated in the direction of the azimuth to make it a one dimensional problem.

The horizon function will search the entire DEM profile for the horizon by finding the maximum slope along the profile. This search is performed in C to significantly speed up the computation.

The values reported from `horizon` are cosine of the horizon angle.

## Sky view factor

The sky view factor (`svf`) is the amount of the sky that is visible to a particular point. The `svf` is between 0 and 1 with 1 indicating no obstructions from surrounding terrain and 0 indicating full obstruction. The `svf` uses the slope, aspect and horizon angles for 72 directions to estimate the sky view factor for the DEM.

# Usage

## Installation

> **NOTE**: `topocalc` has only been tested for Python 3.6 to 3.9 on Linux and MacOSX environments. If building from source, topocalc must be compiled with `gcc`, `clang` will not work if on MacOS.

To install:

`pip install topocalc`

## Gradient usage

```python
from topocalc.gradient import gradient_d8

# Load the DEM into a numpy array
dem = load_dem(path_to_dem)

# grid cell spacing for the DEM
dem_dx = 30
dem_dy = 30

slope, aspect = gradient_d8(dem, dem_dx, dem_dy)
```

## Sky view factor usage

```python
from topocalc.viewf import viewf

# Load the DEM into a numpy array
dem = load_dem(path_to_dem)

# grid cell spacing for the DEM
dem_spacing = 30

svf, tvf = viewf(dem, spacing=dem_spacing)
```

## Command Line Interface

Comming soon!




%package -n python3-topocalc
Summary:	Topo calculations like gradient and sky view
Provides:	python-topocalc
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-topocalc
# topocalc

[![Pypi version](https://img.shields.io/pypi/v/topocalc.svg)](https://pypi.python.org/pypi/topocalc)
[![Coverage Status](https://coveralls.io/repos/github/USDA-ARS-NWRC/topocalc/badge.svg?branch=main)](https://coveralls.io/github/USDA-ARS-NWRC/topocalc?branch=main)
[![Maintainability](https://api.codeclimate.com/v1/badges/20930fef2e7b7fe91dd3/maintainability)](https://codeclimate.com/github/USDA-ARS-NWRC/topocalc/maintainability)

The `topocalc` package is a collection of functions to calculate various metrics on a digital elevation model (DEM). The calculations follow the equations laid out in [Dozier and Frew, 1990](https://doi.org/10.1109/36.58986) for the gradient, horizon and sky view factor. Currently the supported calculations are:

1. Gradient for slope and aspect
2. Horizon angles for an azimuth
3. Sky view factor for percent of the sky that is visible from a point on the DEM

- [topocalc](#topocalc)
- [Background](#background)
  - [Azimuth convention](#azimuth-convention)
  - [Gradient for slope and aspect](#gradient-for-slope-and-aspect)
  - [Horizon angles](#horizon-angles)
  - [Sky view factor](#sky-view-factor)
- [Usage](#usage)
  - [Installation](#installation)
  - [Gradient usage](#gradient-usage)
  - [Sky view factor usage](#sky-view-factor-usage)
  - [Command Line Interface](#command-line-interface)

# Background

## Azimuth convention

For the azimuth's and aspects, the convention is that South is 0 degrees (0 radians) with positive values to the East (+90 degrees or pi/4 radians) and negative values to the West (-90 degrees or -pi/4 radians). North is -180 degrees or -pi/2.

## Gradient for slope and aspect

The gradient method calculates the slope and aspect of the input DEM. There are two methods in `topocalc.gradient` the `gradient_d4` and `gradient_d8`.

`gradient_d4` mimics the slope and aspect calculations of the [IPW `gradient`](https://github.com/USDA-ARS-NWRC/ipw/tree/main/src/bin/topocalc/gradient) function. This calculates the slope for a finite difference in just the x/y direction.

`gradient_d8` (the default) uses a second order finite difference for a 3x3 square around a given point on the DEM.

The gradient is used to calculate the aspect from North (0 degrees). A conversion function will take the aspect in degrees and convert to radians with South being 0.

## Horizon angles

The horizon angle for a point on the DEM is the angle from zenith to the horizon for a given azimuth. Following the methods laid out in [Dozier and Frew, 1990](https://doi.org/10.1109/36.58986) and in [IPW `horizon`](https://github.com/USDA-ARS-NWRC/ipw/tree/main/src/bin/topocalc/horizon) the grid is rotated in the direction of the azimuth to make it a one dimensional problem.

The horizon function will search the entire DEM profile for the horizon by finding the maximum slope along the profile. This search is performed in C to significantly speed up the computation.

The values reported from `horizon` are cosine of the horizon angle.

## Sky view factor

The sky view factor (`svf`) is the amount of the sky that is visible to a particular point. The `svf` is between 0 and 1 with 1 indicating no obstructions from surrounding terrain and 0 indicating full obstruction. The `svf` uses the slope, aspect and horizon angles for 72 directions to estimate the sky view factor for the DEM.

# Usage

## Installation

> **NOTE**: `topocalc` has only been tested for Python 3.6 to 3.9 on Linux and MacOSX environments. If building from source, topocalc must be compiled with `gcc`, `clang` will not work if on MacOS.

To install:

`pip install topocalc`

## Gradient usage

```python
from topocalc.gradient import gradient_d8

# Load the DEM into a numpy array
dem = load_dem(path_to_dem)

# grid cell spacing for the DEM
dem_dx = 30
dem_dy = 30

slope, aspect = gradient_d8(dem, dem_dx, dem_dy)
```

## Sky view factor usage

```python
from topocalc.viewf import viewf

# Load the DEM into a numpy array
dem = load_dem(path_to_dem)

# grid cell spacing for the DEM
dem_spacing = 30

svf, tvf = viewf(dem, spacing=dem_spacing)
```

## Command Line Interface

Comming soon!




%package help
Summary:	Development documents and examples for topocalc
Provides:	python3-topocalc-doc
%description help
# topocalc

[![Pypi version](https://img.shields.io/pypi/v/topocalc.svg)](https://pypi.python.org/pypi/topocalc)
[![Coverage Status](https://coveralls.io/repos/github/USDA-ARS-NWRC/topocalc/badge.svg?branch=main)](https://coveralls.io/github/USDA-ARS-NWRC/topocalc?branch=main)
[![Maintainability](https://api.codeclimate.com/v1/badges/20930fef2e7b7fe91dd3/maintainability)](https://codeclimate.com/github/USDA-ARS-NWRC/topocalc/maintainability)

The `topocalc` package is a collection of functions to calculate various metrics on a digital elevation model (DEM). The calculations follow the equations laid out in [Dozier and Frew, 1990](https://doi.org/10.1109/36.58986) for the gradient, horizon and sky view factor. Currently the supported calculations are:

1. Gradient for slope and aspect
2. Horizon angles for an azimuth
3. Sky view factor for percent of the sky that is visible from a point on the DEM

- [topocalc](#topocalc)
- [Background](#background)
  - [Azimuth convention](#azimuth-convention)
  - [Gradient for slope and aspect](#gradient-for-slope-and-aspect)
  - [Horizon angles](#horizon-angles)
  - [Sky view factor](#sky-view-factor)
- [Usage](#usage)
  - [Installation](#installation)
  - [Gradient usage](#gradient-usage)
  - [Sky view factor usage](#sky-view-factor-usage)
  - [Command Line Interface](#command-line-interface)

# Background

## Azimuth convention

For the azimuth's and aspects, the convention is that South is 0 degrees (0 radians) with positive values to the East (+90 degrees or pi/4 radians) and negative values to the West (-90 degrees or -pi/4 radians). North is -180 degrees or -pi/2.

## Gradient for slope and aspect

The gradient method calculates the slope and aspect of the input DEM. There are two methods in `topocalc.gradient` the `gradient_d4` and `gradient_d8`.

`gradient_d4` mimics the slope and aspect calculations of the [IPW `gradient`](https://github.com/USDA-ARS-NWRC/ipw/tree/main/src/bin/topocalc/gradient) function. This calculates the slope for a finite difference in just the x/y direction.

`gradient_d8` (the default) uses a second order finite difference for a 3x3 square around a given point on the DEM.

The gradient is used to calculate the aspect from North (0 degrees). A conversion function will take the aspect in degrees and convert to radians with South being 0.

## Horizon angles

The horizon angle for a point on the DEM is the angle from zenith to the horizon for a given azimuth. Following the methods laid out in [Dozier and Frew, 1990](https://doi.org/10.1109/36.58986) and in [IPW `horizon`](https://github.com/USDA-ARS-NWRC/ipw/tree/main/src/bin/topocalc/horizon) the grid is rotated in the direction of the azimuth to make it a one dimensional problem.

The horizon function will search the entire DEM profile for the horizon by finding the maximum slope along the profile. This search is performed in C to significantly speed up the computation.

The values reported from `horizon` are cosine of the horizon angle.

## Sky view factor

The sky view factor (`svf`) is the amount of the sky that is visible to a particular point. The `svf` is between 0 and 1 with 1 indicating no obstructions from surrounding terrain and 0 indicating full obstruction. The `svf` uses the slope, aspect and horizon angles for 72 directions to estimate the sky view factor for the DEM.

# Usage

## Installation

> **NOTE**: `topocalc` has only been tested for Python 3.6 to 3.9 on Linux and MacOSX environments. If building from source, topocalc must be compiled with `gcc`, `clang` will not work if on MacOS.

To install:

`pip install topocalc`

## Gradient usage

```python
from topocalc.gradient import gradient_d8

# Load the DEM into a numpy array
dem = load_dem(path_to_dem)

# grid cell spacing for the DEM
dem_dx = 30
dem_dy = 30

slope, aspect = gradient_d8(dem, dem_dx, dem_dy)
```

## Sky view factor usage

```python
from topocalc.viewf import viewf

# Load the DEM into a numpy array
dem = load_dem(path_to_dem)

# grid cell spacing for the DEM
dem_spacing = 30

svf, tvf = viewf(dem, spacing=dem_spacing)
```

## Command Line Interface

Comming soon!




%prep
%autosetup -n topocalc-0.5.0

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-topocalc -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Fri Jun 09 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.0-1
- Package Spec generated