huff 1.1.2__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 +2 -2
- huff/models.py +840 -128
- huff/ors.py +2 -2
- huff/tests/data/Wieland2015.xlsx +0 -0
- huff/tests/tests_huff.py +95 -44
- {huff-1.1.2.dist-info → huff-1.2.0.dist-info}/METADATA +12 -6
- {huff-1.1.2.dist-info → huff-1.2.0.dist-info}/RECORD +9 -8
- {huff-1.1.2.dist-info → huff-1.2.0.dist-info}/WHEEL +0 -0
- {huff-1.1.2.dist-info → huff-1.2.0.dist-info}/top_level.txt +0 -0
huff/ors.py
CHANGED
@@ -4,8 +4,8 @@
|
|
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-05-
|
7
|
+
# Version: 1.2.0
|
8
|
+
# Last update: 2025-05-14 18:28
|
9
9
|
# Copyright (c) 2025 Thomas Wieland
|
10
10
|
#-----------------------------------------------------------------------
|
11
11
|
|
Binary file
|
huff/tests/tests_huff.py
CHANGED
@@ -4,99 +4,150 @@
|
|
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-05-
|
7
|
+
# Version: 1.2.0
|
8
|
+
# Last update: 2025-05-14 18:33
|
9
9
|
# Copyright (c) 2025 Thomas Wieland
|
10
10
|
#-----------------------------------------------------------------------
|
11
11
|
|
12
12
|
|
13
|
-
from huff.
|
14
|
-
from huff.models import load_geodata, create_interaction_matrix
|
13
|
+
from huff.models import create_interaction_matrix, get_isochrones, load_geodata, load_interaction_matrix
|
15
14
|
|
16
|
-
|
17
|
-
# Isochrones test:
|
18
|
-
|
19
|
-
output_path = "."
|
20
|
-
|
21
|
-
ors_client = Client(
|
22
|
-
auth = "5b3ce3597851110001cf62480a15aafdb5a64f4d91805929f8af6abd"
|
23
|
-
)
|
24
|
-
|
25
|
-
isochrone_ORS = ors_client.isochrone (
|
26
|
-
locations = [[7.593301534652711, 47.54329763735186], [9.207916,49.153868]],
|
27
|
-
save_output = True,
|
28
|
-
output_filepath = "test_isochrones.shp",
|
29
|
-
intersections="false"
|
30
|
-
)
|
31
|
-
|
32
|
-
isochrone_ORS.summary()
|
33
|
-
|
34
|
-
# Matrix test:
|
35
|
-
|
36
|
-
matrix_ORS = ors_client.matrix(
|
37
|
-
locations=[[9.70093,48.477473],[9.207916,49.153868],[37.573242,55.801281],[115.663757,38.106467]],
|
38
|
-
save_output=True,
|
39
|
-
output_filepath="test_matrix.csv"
|
40
|
-
)
|
41
|
-
|
42
|
-
matrix_ORS.summary()
|
43
|
-
|
44
|
-
|
45
|
-
# Huff model test data:
|
15
|
+
# Customer origins (statistical districts):
|
46
16
|
|
47
17
|
Haslach = load_geodata(
|
48
18
|
"data/Haslach.shp",
|
49
19
|
location_type="origins",
|
50
20
|
unique_id="BEZEICHN"
|
51
21
|
)
|
22
|
+
# Loading customer origins (shapefile)
|
52
23
|
|
53
24
|
Haslach.summary()
|
25
|
+
# Summary of customer origins
|
54
26
|
|
55
27
|
Haslach.define_marketsize("pop")
|
28
|
+
# Definition of market size variable
|
56
29
|
|
57
30
|
Haslach.define_transportcosts_weighting(
|
58
|
-
param_lambda
|
31
|
+
param_lambda = -2.2
|
59
32
|
)
|
33
|
+
# Definition of transport costs weighting (lambda)
|
60
34
|
|
61
35
|
Haslach.summary()
|
36
|
+
# Summary after update
|
62
37
|
|
63
38
|
|
39
|
+
# Supply locations (supermarkets):
|
40
|
+
|
64
41
|
Haslach_supermarkets = load_geodata(
|
65
42
|
"data/Haslach_supermarkets.shp",
|
66
43
|
location_type="destinations",
|
67
44
|
unique_id="LFDNR"
|
68
45
|
)
|
46
|
+
# Loading supply locations (shapefile)
|
69
47
|
|
70
48
|
Haslach_supermarkets.summary()
|
71
|
-
|
72
|
-
Haslach_supermarkets.isochrones(
|
73
|
-
save_output=True,
|
74
|
-
ors_auth = "5b3ce3597851110001cf62480a15aafdb5a64f4d91805929f8af6abd",
|
75
|
-
output_filepath="Haslach_supermarkets_iso.shp"
|
76
|
-
)
|
49
|
+
# Summary of supply locations
|
77
50
|
|
78
51
|
Haslach_supermarkets.define_attraction("VKF_qm")
|
52
|
+
# Defining attraction variable
|
79
53
|
|
80
54
|
Haslach_supermarkets.define_attraction_weighting(
|
81
55
|
param_gamma=0.9
|
82
56
|
)
|
57
|
+
# Define attraction weighting (gamma)
|
83
58
|
|
84
|
-
Haslach_supermarkets.
|
59
|
+
# Haslach_supermarkets.isochrones(
|
60
|
+
# segments_minutes=[5, 10, 15],
|
61
|
+
# profile = "driving-car",
|
62
|
+
# save_output=True,
|
63
|
+
# ors_auth="5b3ce3597851110001cf62480a15aafdb5a64f4d91805929f8af6abd",
|
64
|
+
# output_filepath="Haslach_supermarkets_iso.shp"
|
65
|
+
# )
|
66
|
+
# # Obtaining isochrones for driving by car (5, 10 and 15 minutes)
|
85
67
|
|
68
|
+
# Haslach_supermarkets.summary()
|
69
|
+
# # Summary of updated customer origins
|
70
|
+
|
71
|
+
# Haslach_supermarkets_isochrones = Haslach_supermarkets.get_isochrones_gdf()
|
72
|
+
# # Extracting isochrones
|
73
|
+
|
74
|
+
# print(Haslach_supermarkets_isochrones)
|
75
|
+
|
76
|
+
|
77
|
+
# Using customer origins and supply locations for building interaction matrix:
|
86
78
|
|
87
79
|
haslach_interactionmatrix = create_interaction_matrix(
|
88
80
|
Haslach,
|
89
81
|
Haslach_supermarkets
|
90
82
|
)
|
83
|
+
# Creating interaction matrix
|
91
84
|
|
92
85
|
interaction_matrix = haslach_interactionmatrix.transport_costs(
|
93
|
-
ors_auth="5b3ce3597851110001cf62480a15aafdb5a64f4d91805929f8af6abd"
|
86
|
+
#ors_auth="5b3ce3597851110001cf62480a15aafdb5a64f4d91805929f8af6abd"
|
87
|
+
network=False
|
94
88
|
)
|
89
|
+
# Obtaining transport costs (default: driving-car)
|
95
90
|
|
96
91
|
interaction_matrix = interaction_matrix.flows()
|
92
|
+
# Calculating spatial flows
|
97
93
|
|
98
94
|
huff_model = interaction_matrix.marketareas()
|
95
|
+
# Calculating total market areas
|
96
|
+
|
97
|
+
huff_model.summary()
|
98
|
+
# Summary of Huff model
|
99
|
+
|
100
|
+
print(huff_model.get_market_areas_df())
|
101
|
+
# Showing total market areas
|
99
102
|
|
100
103
|
print(interaction_matrix.get_interaction_matrix_df())
|
104
|
+
# Showing df of interaction matrix
|
105
|
+
|
106
|
+
|
107
|
+
# Multiplicative Competitive Interaction Model:
|
108
|
+
|
109
|
+
mci_fit = huff_model.mci_fit()
|
110
|
+
# Fitting via MCI
|
111
|
+
|
112
|
+
mci_fit.summary()
|
113
|
+
# Summary of MCI model
|
114
|
+
|
115
|
+
mci_fit.marketareas()
|
116
|
+
# MCI model market simulation
|
117
|
+
|
118
|
+
mci_fit.get_market_areas_df()
|
119
|
+
# MCI model market areas
|
120
|
+
|
121
|
+
|
122
|
+
# Loading own interaction matrix:
|
123
|
+
|
124
|
+
Wieland2015_interaction_matrix = load_interaction_matrix(
|
125
|
+
data="data/Wieland2015.xlsx",
|
126
|
+
customer_origins_col="Quellort",
|
127
|
+
supply_locations_col="Zielort",
|
128
|
+
attraction_col=[
|
129
|
+
"VF",
|
130
|
+
"K",
|
131
|
+
"K_KKr"
|
132
|
+
],
|
133
|
+
transport_costs_col="Dist_Min2",
|
134
|
+
probabilities_col="MA",
|
135
|
+
data_type="xlsx"
|
136
|
+
)
|
137
|
+
# Data source: Wieland 2015 (https://nbn-resolving.org/urn:nbn:de:bvb:20-opus-180753)
|
138
|
+
|
139
|
+
Wieland2015_interaction_matrix.summary()
|
140
|
+
# Summary of interaction matrix
|
141
|
+
|
142
|
+
Wieland2015_fit = Wieland2015_interaction_matrix.mci_fit(
|
143
|
+
cols=[
|
144
|
+
"A_j",
|
145
|
+
"t_ij",
|
146
|
+
"K",
|
147
|
+
"K_KKr"
|
148
|
+
]
|
149
|
+
)
|
150
|
+
# Fitting MCI model with four independent variables
|
101
151
|
|
102
|
-
|
152
|
+
Wieland2015_fit.summary()
|
153
|
+
# MCI model summary
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: huff
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.2.0
|
4
4
|
Summary: huff: Huff Model Market Area Analysis
|
5
5
|
Author: Thomas Wieland
|
6
6
|
Author-email: geowieland@googlemail.com
|
@@ -8,6 +8,10 @@ Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: geopandas
|
9
9
|
Requires-Dist: pandas
|
10
10
|
Requires-Dist: numpy
|
11
|
+
Requires-Dist: time
|
12
|
+
Requires-Dist: statsmodels
|
13
|
+
Requires-Dist: shapely
|
14
|
+
Requires-Dist: request
|
11
15
|
|
12
16
|
# huff: Huff Model Market Area Analysis
|
13
17
|
|
@@ -26,14 +30,16 @@ See the /tests directory for usage examples of most of the included functions.
|
|
26
30
|
- Calculating basic Huff Model
|
27
31
|
- **Multiplicative Competitive Interaction Model**:
|
28
32
|
- Log-centering transformation
|
29
|
-
-
|
33
|
+
- Fitting MCI model with >= independent variables
|
34
|
+
- **OpenRouteService Client** (1) (Tools via API):
|
30
35
|
- Creating transport costs matrix from origins and destinations
|
31
36
|
- Creating isochrones from destinations
|
37
|
+
- **Tools**:
|
38
|
+
- Loading own interaction matrix for analysis
|
39
|
+
- GIS tools for preparing geodata
|
32
40
|
|
33
|
-
Attribution of OpenRouteService:
|
34
|
-
© openrouteservice.org by HeiGIT | Map data © OpenStreetMap contributors
|
35
|
-
|
36
|
-
Visit https://openrouteservice.org/
|
41
|
+
(1) Attribution of OpenRouteService:
|
42
|
+
© openrouteservice.org by HeiGIT | Map data © OpenStreetMap contributors | https://openrouteservice.org/
|
37
43
|
|
38
44
|
## Literature
|
39
45
|
- Huff DL (1962) *Determination of Intra-Urban Retail Trade Areas*.
|
@@ -1,9 +1,9 @@
|
|
1
1
|
huff/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
huff/gistools.py,sha256=
|
3
|
-
huff/models.py,sha256=
|
4
|
-
huff/ors.py,sha256=
|
2
|
+
huff/gistools.py,sha256=hfTP8zEQwlPMp505IgEl9uT5nJczBABxVsQ5MVE8fIU,2721
|
3
|
+
huff/models.py,sha256=ilDSe9jdpOz75GJ3m8fKl2JOUpIOXv1pM2HVgj5_TTs,57180
|
4
|
+
huff/ors.py,sha256=fyh-82nddvwCVpn1nZ3J0pZa6VrshUDeZSxm0aXvSiI,11467
|
5
5
|
huff/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
huff/tests/tests_huff.py,sha256=
|
6
|
+
huff/tests/tests_huff.py,sha256=hsB81I9aJGuBT-NHYrV62U6UB6lWAV13WbOM3tSRvu4,4039
|
7
7
|
huff/tests/data/Haslach.cpg,sha256=OtMDH1UDpEBK-CUmLugjLMBNTqZoPULF3QovKiesmCQ,5
|
8
8
|
huff/tests/data/Haslach.dbf,sha256=GVPIt05OzDO7UrRDcsMhiYWvyXAPg6Z-qkiysFzj-fc,506
|
9
9
|
huff/tests/data/Haslach.prj,sha256=2Jy1Vlzh7UxQ1MXpZ9UYLs2SxfrObj2xkEkZyLqmGTY,437
|
@@ -16,7 +16,8 @@ huff/tests/data/Haslach_supermarkets.prj,sha256=2Jy1Vlzh7UxQ1MXpZ9UYLs2SxfrObj2x
|
|
16
16
|
huff/tests/data/Haslach_supermarkets.qmd,sha256=j9i4_Pz7ZMSG2UDSb3nuhJpw0KWXIRhiiDymqJP6_Fo,2479
|
17
17
|
huff/tests/data/Haslach_supermarkets.shp,sha256=X7QbQ0BTMag_B-bDRbpr-go2BQIXo3Y8zMAKpYZmlps,324
|
18
18
|
huff/tests/data/Haslach_supermarkets.shx,sha256=j23QHX-SmdAeN04rw0x8nUOran-OCg_T6r_LvzzEPWs,164
|
19
|
-
huff
|
20
|
-
huff-1.
|
21
|
-
huff-1.
|
22
|
-
huff-1.
|
19
|
+
huff/tests/data/Wieland2015.xlsx,sha256=SaVM-Hi5dBTmf2bzszMnZ2Ec8NUE05S_5F2lQj0ayS0,19641
|
20
|
+
huff-1.2.0.dist-info/METADATA,sha256=U79cQVxYruPuRBCeQ8sZ9Xysf3sTnOJY8WtZt4qxL6k,2793
|
21
|
+
huff-1.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
22
|
+
huff-1.2.0.dist-info/top_level.txt,sha256=nlzX-PxZNFmIxANIJMySuIFPihd6qOBkRlhIC28NEsQ,5
|
23
|
+
huff-1.2.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|