huff 1.1.1__py3-none-any.whl → 1.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- huff/gistools.py +50 -3
- huff/models.py +907 -172
- huff/ors.py +2 -2
- huff/tests/data/Wieland2015.xlsx +0 -0
- huff/tests/tests_huff.py +95 -44
- {huff-1.1.1.dist-info → huff-1.2.0.dist-info}/METADATA +12 -5
- {huff-1.1.1.dist-info → huff-1.2.0.dist-info}/RECORD +9 -8
- {huff-1.1.1.dist-info → huff-1.2.0.dist-info}/WHEEL +0 -0
- {huff-1.1.1.dist-info → huff-1.2.0.dist-info}/top_level.txt +0 -0
huff/gistools.py
CHANGED
@@ -4,13 +4,60 @@
|
|
4
4
|
# Author: Thomas Wieland
|
5
5
|
# ORCID: 0000-0001-5168-9846
|
6
6
|
# mail: geowieland@googlemail.com
|
7
|
-
# Version: 1.
|
8
|
-
# Last update: 2025-
|
7
|
+
# Version: 1.2.0
|
8
|
+
# Last update: 2025-05-14 18:28
|
9
9
|
# Copyright (c) 2025 Thomas Wieland
|
10
10
|
#-----------------------------------------------------------------------
|
11
11
|
|
12
12
|
|
13
|
-
import geopandas as gp
|
13
|
+
import geopandas as gp
|
14
|
+
from math import pi, sin, cos, acos
|
15
|
+
|
16
|
+
|
17
|
+
def distance_matrix(
|
18
|
+
sources: list,
|
19
|
+
destinations: list,
|
20
|
+
unit: str = "m",
|
21
|
+
):
|
22
|
+
|
23
|
+
def euclidean_distance (
|
24
|
+
source: list,
|
25
|
+
destination: list,
|
26
|
+
unit: str = "m"
|
27
|
+
):
|
28
|
+
|
29
|
+
lon1 = source[0]
|
30
|
+
lat1 = source[1]
|
31
|
+
lon2 = destination[0]
|
32
|
+
lat2 = destination[1]
|
33
|
+
|
34
|
+
lat1_r = lat1*pi/180
|
35
|
+
lon1_r = lon1*pi/180
|
36
|
+
lat2_r = lat2*pi/180
|
37
|
+
lon2_r = lon2*pi/180
|
38
|
+
|
39
|
+
distance = 6378 * (acos(sin(lat1_r) * sin(lat2_r) + cos(lat1_r) * cos(lat2_r) * cos(lon2_r - lon1_r)))
|
40
|
+
if unit == "m":
|
41
|
+
distance = distance*1000
|
42
|
+
if unit == "mile":
|
43
|
+
distance = distance/1.60934
|
44
|
+
|
45
|
+
return distance
|
46
|
+
|
47
|
+
matrix = []
|
48
|
+
|
49
|
+
for source in sources:
|
50
|
+
row = []
|
51
|
+
for destination in destinations:
|
52
|
+
dist = euclidean_distance(
|
53
|
+
source,
|
54
|
+
destination,
|
55
|
+
unit
|
56
|
+
)
|
57
|
+
row.append(dist)
|
58
|
+
matrix.append(row)
|
59
|
+
|
60
|
+
return matrix
|
14
61
|
|
15
62
|
|
16
63
|
def overlay_difference(
|