ssb-sgis 1.2.13__py3-none-any.whl → 1.2.14__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.
- sgis/maps/legend.py +11 -3
- sgis/maps/thematicmap.py +15 -15
- sgis/networkanalysis/_get_route.py +2 -1
- sgis/networkanalysis/_service_area.py +3 -1
- sgis/networkanalysis/networkanalysis.py +18 -18
- {ssb_sgis-1.2.13.dist-info → ssb_sgis-1.2.14.dist-info}/METADATA +1 -1
- {ssb_sgis-1.2.13.dist-info → ssb_sgis-1.2.14.dist-info}/RECORD +9 -9
- {ssb_sgis-1.2.13.dist-info → ssb_sgis-1.2.14.dist-info}/LICENSE +0 -0
- {ssb_sgis-1.2.13.dist-info → ssb_sgis-1.2.14.dist-info}/WHEEL +0 -0
sgis/maps/legend.py
CHANGED
|
@@ -330,6 +330,8 @@ class Legend:
|
|
|
330
330
|
framealpha=self.framealpha,
|
|
331
331
|
edgecolor=self.edgecolor,
|
|
332
332
|
labelspacing=self.labelspacing,
|
|
333
|
+
facecolor=self.facecolor,
|
|
334
|
+
labelcolor=self.labelcolor,
|
|
333
335
|
**self.kwargs,
|
|
334
336
|
)
|
|
335
337
|
|
|
@@ -344,16 +346,22 @@ class Legend:
|
|
|
344
346
|
minx, miny, maxx, maxy = gdf.total_bounds
|
|
345
347
|
diffx = maxx - minx
|
|
346
348
|
diffy = maxy - miny
|
|
347
|
-
|
|
349
|
+
if diffx > 10000 and diffy > 10000:
|
|
350
|
+
gridsize = (diffy + diffx) // 1000
|
|
351
|
+
if diffx > 1000 and diffy > 1000:
|
|
352
|
+
gridsize = (diffy + diffx) // 100
|
|
353
|
+
if diffx > 100 and diffy > 100:
|
|
354
|
+
gridsize = (diffy + diffx) // 10
|
|
355
|
+
else:
|
|
356
|
+
gridsize = 30
|
|
348
357
|
points = pd.concat(
|
|
349
358
|
[
|
|
350
|
-
points_in_bounds(gdf,
|
|
359
|
+
points_in_bounds(gdf, gridsize),
|
|
351
360
|
bounds_to_points(gdf)
|
|
352
361
|
.geometry.explode(ignore_index=True)
|
|
353
362
|
.to_frame("geometry"),
|
|
354
363
|
]
|
|
355
364
|
)
|
|
356
|
-
|
|
357
365
|
gdf = gdf.loc[:, ~gdf.columns.str.contains("index|level_")]
|
|
358
366
|
joined = points.sjoin_nearest(gdf, distance_col="nearest")
|
|
359
367
|
|
sgis/maps/thematicmap.py
CHANGED
|
@@ -253,18 +253,13 @@ class ThematicMap(Map):
|
|
|
253
253
|
self._dark = self._dark or black
|
|
254
254
|
|
|
255
255
|
if not self.cmap and not self._is_categorical:
|
|
256
|
-
self._choose_cmap()
|
|
256
|
+
self._choose_cmap(**kwargs)
|
|
257
257
|
|
|
258
258
|
if not legend:
|
|
259
259
|
self.legend = None
|
|
260
260
|
else:
|
|
261
261
|
self._create_legend()
|
|
262
262
|
|
|
263
|
-
self._dark_or_light()
|
|
264
|
-
|
|
265
|
-
if cmap:
|
|
266
|
-
self._cmap = cmap
|
|
267
|
-
|
|
268
263
|
new_kwargs = {}
|
|
269
264
|
for key, value in self.kwargs.items():
|
|
270
265
|
if key not in MAP_KWARGS:
|
|
@@ -286,6 +281,11 @@ class ThematicMap(Map):
|
|
|
286
281
|
except Exception:
|
|
287
282
|
setattr(self.legend, f"_{key}", value)
|
|
288
283
|
|
|
284
|
+
self._dark_or_light()
|
|
285
|
+
|
|
286
|
+
if cmap:
|
|
287
|
+
self._cmap = cmap
|
|
288
|
+
|
|
289
289
|
self.bounds = (
|
|
290
290
|
to_bbox(bounds) if bounds is not None else to_bbox(self._gdf.total_bounds)
|
|
291
291
|
)
|
|
@@ -589,16 +589,16 @@ class ThematicMap(Map):
|
|
|
589
589
|
else:
|
|
590
590
|
self.legend = ContinousLegend(title=self._column, size=self._size)
|
|
591
591
|
|
|
592
|
-
def _choose_cmap(self) -> None:
|
|
592
|
+
def _choose_cmap(self, **kwargs) -> None:
|
|
593
593
|
"""Kwargs is to catch start and stop points for the cmap in __init__."""
|
|
594
594
|
if self._dark:
|
|
595
595
|
self._cmap = "viridis"
|
|
596
|
-
self.cmap_start = 0
|
|
597
|
-
self.cmap_stop = 256
|
|
596
|
+
self.cmap_start = self.kwargs.pop("cmap_start", 0)
|
|
597
|
+
self.cmap_stop = self.kwargs.pop("cmap_stop", 256)
|
|
598
598
|
else:
|
|
599
599
|
self._cmap = "RdPu"
|
|
600
|
-
self.cmap_start = 23
|
|
601
|
-
self.cmap_stop = 256
|
|
600
|
+
self.cmap_start = self.kwargs.pop("cmap_start", 23)
|
|
601
|
+
self.cmap_stop = self.kwargs.pop("cmap_stop", 256)
|
|
602
602
|
|
|
603
603
|
def _make_bin_value_dict(self, gdf: GeoDataFrame, classified: np.ndarray) -> dict:
|
|
604
604
|
"""Dict with unique values of all bins. Used in labels in ContinousLegend."""
|
|
@@ -609,8 +609,6 @@ class ThematicMap(Map):
|
|
|
609
609
|
return bins_unique_values
|
|
610
610
|
|
|
611
611
|
def _actually_add_background(self) -> None:
|
|
612
|
-
# self.ax.set_xlim([self.minx - self.diffx * 0.03, self.maxx + self.diffx * 0.03])
|
|
613
|
-
# self.ax.set_ylim([self.miny - self.diffy * 0.03, self.maxy + self.diffy * 0.03])
|
|
614
612
|
self._background_gdfs.plot(
|
|
615
613
|
ax=self.ax, color=self.bg_gdf_color, **self.bg_gdf_kwargs
|
|
616
614
|
)
|
|
@@ -632,13 +630,14 @@ class ThematicMap(Map):
|
|
|
632
630
|
)
|
|
633
631
|
self.nan_color = "#666666" if self._nan_color_was_none else self.nan_color
|
|
634
632
|
if not self._is_categorical:
|
|
635
|
-
self.
|
|
633
|
+
self._cmap = self.kwargs.get("cmap", "viridis")
|
|
636
634
|
|
|
637
635
|
if self.legend is not None:
|
|
638
636
|
for key, color in {
|
|
639
637
|
"facecolor": "#0f0f0f",
|
|
640
638
|
"labelcolor": "#fefefe",
|
|
641
639
|
"title_color": "#fefefe",
|
|
640
|
+
"edgecolor": "#0f0f0f",
|
|
642
641
|
}.items():
|
|
643
642
|
setattr(self.legend, key, color)
|
|
644
643
|
|
|
@@ -650,13 +649,14 @@ class ThematicMap(Map):
|
|
|
650
649
|
)
|
|
651
650
|
self.nan_color = "#c2c2c2" if self._nan_color_was_none else self.nan_color
|
|
652
651
|
if not self._is_categorical:
|
|
653
|
-
self.
|
|
652
|
+
self._cmap = self.kwargs.get("cmap", "RdPu")
|
|
654
653
|
|
|
655
654
|
if self.legend is not None:
|
|
656
655
|
for key, color in {
|
|
657
656
|
"facecolor": "#fefefe",
|
|
658
657
|
"labelcolor": "#0f0f0f",
|
|
659
658
|
"title_color": "#0f0f0f",
|
|
659
|
+
"edgecolor": "#0f0f0f",
|
|
660
660
|
}.items():
|
|
661
661
|
setattr(self.legend, key, color)
|
|
662
662
|
|
|
@@ -2,6 +2,7 @@ import warnings
|
|
|
2
2
|
|
|
3
3
|
import joblib
|
|
4
4
|
import pandas as pd
|
|
5
|
+
import shapely
|
|
5
6
|
from geopandas import GeoDataFrame
|
|
6
7
|
from igraph import Graph
|
|
7
8
|
from pandas import DataFrame
|
|
@@ -116,8 +117,8 @@ def _get_route(
|
|
|
116
117
|
results: DataFrame = pd.concat(resultlist)
|
|
117
118
|
assert list(results.columns) == ["origin", "destination"], list(results.columns)
|
|
118
119
|
lines: GeoDataFrame = _get_line_geometries(results, roads, weight)
|
|
120
|
+
lines.geometry = shapely.force_2d(lines.geometry)
|
|
119
121
|
lines = lines.dissolve(by=["origin", "destination"], aggfunc="sum", as_index=False)
|
|
120
|
-
|
|
121
122
|
return lines[["origin", "destination", weight, "geometry"]]
|
|
122
123
|
|
|
123
124
|
|
|
@@ -129,10 +129,12 @@ def _service_area(
|
|
|
129
129
|
|
|
130
130
|
service_areas.append(edges_within)
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
service_areas = pd.concat(
|
|
133
133
|
service_areas,
|
|
134
134
|
ignore_index=True,
|
|
135
135
|
)
|
|
136
|
+
service_areas.geometry = force_2d(service_areas.geometry)
|
|
137
|
+
return service_areas
|
|
136
138
|
|
|
137
139
|
|
|
138
140
|
def _part_of_edge_within(distance_df, nodes_within_break, directed):
|
|
@@ -17,6 +17,7 @@ from geopandas import GeoDataFrame
|
|
|
17
17
|
from igraph import Graph
|
|
18
18
|
from pandas import DataFrame
|
|
19
19
|
from pandas import MultiIndex
|
|
20
|
+
from shapely import force_2d
|
|
20
21
|
|
|
21
22
|
from ..geopandas_tools.general import _push_geom_col
|
|
22
23
|
from ._get_route import _get_k_routes
|
|
@@ -34,9 +35,20 @@ from .networkanalysisrules import NetworkAnalysisRules
|
|
|
34
35
|
class NetworkAnalysis:
|
|
35
36
|
"""Class for doing network analysis.
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
Args:
|
|
39
|
+
network: A GeoDataFrame of line geometries.
|
|
40
|
+
rules: The rules for the analysis, either as an instance of
|
|
41
|
+
NetworkAnalysisRules or a dictionary with the parameters
|
|
42
|
+
as keys.
|
|
43
|
+
log: If True (default), a DataFrame with information about each
|
|
44
|
+
analysis run will be stored in the 'log' attribute.
|
|
45
|
+
detailed_log: If True, the log DataFrame will include columns for
|
|
46
|
+
all arguments passed to the analysis method, plus standard deviation and
|
|
47
|
+
percentiles (25th, 50th, 75th) of the weight column in the results.
|
|
48
|
+
Defaults to False.
|
|
49
|
+
|
|
50
|
+
The class implements methods for doing network analysis based on
|
|
51
|
+
GeoDataFrames of origin and destination points.
|
|
40
52
|
|
|
41
53
|
The 'od_cost_matrix' method is the fastest, and returns a DataFrame with only
|
|
42
54
|
indices and travel costs between each origin-destination pair.
|
|
@@ -96,21 +108,7 @@ class NetworkAnalysis:
|
|
|
96
108
|
log: bool = True,
|
|
97
109
|
detailed_log: bool = False,
|
|
98
110
|
) -> None:
|
|
99
|
-
"""Initialise NetworkAnalysis instance.
|
|
100
|
-
|
|
101
|
-
Args:
|
|
102
|
-
network: A GeoDataFrame of line geometries.
|
|
103
|
-
rules: The rules for the analysis, either as an instance of
|
|
104
|
-
NetworkAnalysisRules or a dictionary with the parameters
|
|
105
|
-
as keys.
|
|
106
|
-
log: If True (default), a DataFrame with information about each
|
|
107
|
-
analysis run will be stored in the 'log' attribute.
|
|
108
|
-
detailed_log: If True, the log DataFrame will include columns for
|
|
109
|
-
all arguments passed to the analysis method, plus standard deviation and
|
|
110
|
-
percentiles (25th, 50th, 75th) of the weight column in the results.
|
|
111
|
-
Defaults to False.
|
|
112
|
-
|
|
113
|
-
"""
|
|
111
|
+
"""Initialise NetworkAnalysis instance."""
|
|
114
112
|
if not isinstance(rules, NetworkAnalysisRules):
|
|
115
113
|
rules = NetworkAnalysisRules(**rules)
|
|
116
114
|
|
|
@@ -647,6 +645,8 @@ class NetworkAnalysis:
|
|
|
647
645
|
frequency_col
|
|
648
646
|
)
|
|
649
647
|
|
|
648
|
+
results.geometry = force_2d(results.geometry)
|
|
649
|
+
|
|
650
650
|
if self.rules.split_lines:
|
|
651
651
|
self._unsplit_network()
|
|
652
652
|
|
|
@@ -30,24 +30,24 @@ sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
30
30
|
sgis/maps/examine.py,sha256=69nPtMChKmso7Yy8X--UoTWJjKmjMF1VHsdLpPKFbA0,9233
|
|
31
31
|
sgis/maps/explore.py,sha256=ANbhScthhwznLEUDDjRUBmniGmkdF9zftbzp9dYHu-U,48210
|
|
32
32
|
sgis/maps/httpserver.py,sha256=I7tTn3hFaTCc-E-T_o9v0nXwMGaS2Xqd4MlWbq8k-J4,3014
|
|
33
|
-
sgis/maps/legend.py,sha256=
|
|
33
|
+
sgis/maps/legend.py,sha256=6L6KspAoYuQbOcs-0vWzMDEL_9qvmGuRR7VIL1wsBMI,26898
|
|
34
34
|
sgis/maps/map.py,sha256=07YK_oHa2z_yw_es06pd-80dV8YTI5mkTyJxyud707Y,30758
|
|
35
35
|
sgis/maps/maps.py,sha256=fLK5WUlQ2YTm7t-8260lYxCFvpZN6j0Y-bVYCyv8NAY,23249
|
|
36
36
|
sgis/maps/norge_i_bilder.json,sha256=G9DIN_2vyn-18UF5wUC-koZxFCbiNxMu0BbCJhMFJUk,15050340
|
|
37
|
-
sgis/maps/thematicmap.py,sha256=
|
|
37
|
+
sgis/maps/thematicmap.py,sha256=ZtV4Hfylr1ST_cPzi11_lFIsTdY3D1o1EZQbPXZLwyM,25187
|
|
38
38
|
sgis/maps/tilesources.py,sha256=F4mFHxPwkiPJdVKzNkScTX6xbJAMIUtlTq4mQ83oguw,1746
|
|
39
39
|
sgis/maps/wms.py,sha256=3ZPf-H3sirvHeLQdXGwE3j6w1sFQCkExsEWkvHl7a4g,11233
|
|
40
40
|
sgis/networkanalysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
-
sgis/networkanalysis/_get_route.py,sha256=
|
|
41
|
+
sgis/networkanalysis/_get_route.py,sha256=3m5xQdQqGtt51vcI5fcmYQAOQCeBtL6sorDoPxBNf84,7818
|
|
42
42
|
sgis/networkanalysis/_od_cost_matrix.py,sha256=zkyPX7ObT996ahaFJ2oI0D0SqQWbWyfy_qLtXwValPg,3434
|
|
43
43
|
sgis/networkanalysis/_points.py,sha256=128QEepBGAyI5XakMUVvNyOnJE0Ts7hvGiVUt1YTXiU,4439
|
|
44
|
-
sgis/networkanalysis/_service_area.py,sha256
|
|
44
|
+
sgis/networkanalysis/_service_area.py,sha256=-xSdiZrZ3uqAhd4ZaBY8a8fMJjN09MPoYxlVMXm3UZk,5642
|
|
45
45
|
sgis/networkanalysis/closing_network_holes.py,sha256=FYZ677nRwLmDkP6bQ1ssQ_h29RzAG463U4xmbu5ksfg,14572
|
|
46
46
|
sgis/networkanalysis/cutting_lines.py,sha256=ZQAt0cufaPeNAEqUzp-imu26AIL9S5-lw6Xifa8RoWk,9818
|
|
47
47
|
sgis/networkanalysis/directednetwork.py,sha256=Mrc2zHip4P5RNxnyffKm-xU832AVQeSHz-YZueAc0pM,11413
|
|
48
48
|
sgis/networkanalysis/finding_isolated_networks.py,sha256=Wg4ILhm7uS9RLOGcL0WN8uZBMJYjdljJc8L5DU5nIPY,3754
|
|
49
49
|
sgis/networkanalysis/network.py,sha256=zV9bAbVdTgTohg2o2RFGy2uhOJrd3Ma57hwIAStxMAQ,7847
|
|
50
|
-
sgis/networkanalysis/networkanalysis.py,sha256=
|
|
50
|
+
sgis/networkanalysis/networkanalysis.py,sha256=P2kqE1kBxabBnv4h6ort1IiO4W0XlsJn5DrT7IbeG5w,68651
|
|
51
51
|
sgis/networkanalysis/networkanalysisrules.py,sha256=9sXigaCzvKhXFwpeVNMtOiIK3_Hzp9yDpFklmEEAPak,12956
|
|
52
52
|
sgis/networkanalysis/nodes.py,sha256=atFSpqz-_uJHMrf6MC0zhrrcWIydRMFZrsaHC2xr1GU,3374
|
|
53
53
|
sgis/networkanalysis/traveling_salesman.py,sha256=Jjo6bHY4KJ-eK0LycyTy0sWxZjgITs5MBllZ_G9FhTE,5655
|
|
@@ -61,7 +61,7 @@ sgis/raster/indices.py,sha256=efJmgfPg_VuSzXFosXV661IendF8CwPFWtMhyP4TMUg,222
|
|
|
61
61
|
sgis/raster/regex.py,sha256=4idTJ9vFtsGtbxcjJrx2VrpJJuDMP3bLdqF93Vc_cmY,3752
|
|
62
62
|
sgis/raster/sentinel_config.py,sha256=nySDqn2R8M6W8jguoBeSAK_zzbAsqmaI59i32446FwY,1268
|
|
63
63
|
sgis/raster/zonal.py,sha256=D4Gyptw-yOLTCO41peIuYbY-DANsJCG19xXDlf1QAz4,2299
|
|
64
|
-
ssb_sgis-1.2.
|
|
65
|
-
ssb_sgis-1.2.
|
|
66
|
-
ssb_sgis-1.2.
|
|
67
|
-
ssb_sgis-1.2.
|
|
64
|
+
ssb_sgis-1.2.14.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
|
|
65
|
+
ssb_sgis-1.2.14.dist-info/METADATA,sha256=Hhvwb5ydmsvVBuINCUdiElVrH2SZaZ-XThmYG_rtGA4,11741
|
|
66
|
+
ssb_sgis-1.2.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
67
|
+
ssb_sgis-1.2.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|