ssb-sgis 1.0.8__py3-none-any.whl → 1.0.9__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/raster/regex.py CHANGED
@@ -74,7 +74,7 @@ def _extract_regex_match_from_string(
74
74
  return re.search(regex, xml_file).group(1)
75
75
  except (TypeError, AttributeError, IndexError):
76
76
  continue
77
- raise _RegexError()
77
+ raise _RegexError(regexes)
78
78
 
79
79
  out = {}
80
80
  for regex in regexes:
@@ -84,7 +84,7 @@ def _extract_regex_match_from_string(
84
84
  except (TypeError, AttributeError):
85
85
  continue
86
86
  if not out:
87
- raise _RegexError()
87
+ raise _RegexError(regexes)
88
88
  return out
89
89
 
90
90
 
sgis/raster/zonal.py CHANGED
@@ -5,7 +5,6 @@ import geopandas as gpd
5
5
  import numpy as np
6
6
  import pandas as pd
7
7
  from shapely import Geometry
8
- from shapely.geometry import Polygon
9
8
 
10
9
  from ..helpers import get_non_numpy_func_name
11
10
  from ..helpers import get_numpy_func
@@ -28,46 +27,10 @@ def _prepare_zonal(
28
27
 
29
28
 
30
29
  def _make_geometry_iterrows(gdf: gpd.GeoDataFrame) -> list[tuple[int, Geometry]]:
31
- """Because pandas iterrows returns non-geo Series."""
30
+ """Because pandas iterrows returns Series, not GeoSeries."""
32
31
  return list(gdf.geometry.items())
33
32
 
34
33
 
35
- def _zonal_func(
36
- poly_iter: tuple[int, Polygon],
37
- cube,
38
- array_func: Callable,
39
- aggfunc: str | Callable | Sequence[Callable | str],
40
- func_names: list[str],
41
- by_date: bool,
42
- ) -> pd.DataFrame:
43
- cube = cube.copy()
44
- i, polygon = poly_iter
45
- if not by_date or cube.date.isna().all():
46
- df = _clip_and_aggregate(
47
- cube, polygon, array_func, aggfunc, func_names, date=None, i=i
48
- )
49
- return df if by_date else df.drop(columns="date")
50
-
51
- out = []
52
-
53
- na_date = cube[cube.date.isna()]
54
- df = _clip_and_aggregate(
55
- na_date, polygon, array_func, aggfunc, func_names, date=pd.NA, i=i
56
- )
57
- out.append(df)
58
-
59
- cube = cube[lambda x: x["date"].notna()]
60
-
61
- for dt in cube.date.unique():
62
- cube_date = cube[cube.date == dt]
63
- df = _clip_and_aggregate(
64
- cube_date, polygon, array_func, aggfunc, func_names, dt, i
65
- )
66
- out.append(df)
67
-
68
- return pd.concat(out)
69
-
70
-
71
34
  def _no_overlap_df(func_names: list[str], i: int, date: str) -> pd.DataFrame:
72
35
  df = pd.DataFrame(columns=func_names, index=[i])
73
36
  df["date"] = date
@@ -75,26 +38,6 @@ def _no_overlap_df(func_names: list[str], i: int, date: str) -> pd.DataFrame:
75
38
  return df
76
39
 
77
40
 
78
- def _clip_and_aggregate(
79
- cube,
80
- polygon: Geometry,
81
- array_func: Callable,
82
- aggfunc: Callable,
83
- func_names: list[str],
84
- date: str,
85
- i: int,
86
- ) -> pd.DataFrame:
87
- if not len(cube):
88
- return _no_overlap_df(func_names, i, date)
89
- clipped = cube.clipmerge(polygon)
90
- if not len(clipped) or [arr is None for arr in clipped.arrays]:
91
- return _no_overlap_df(func_names, i, date)
92
- assert len(clipped) == 1
93
- array = clipped[0].array
94
- df = _aggregate(array, array_func, aggfunc, func_names, date, i)
95
- return df
96
-
97
-
98
41
  def _aggregate(
99
42
  array: np.ndarray,
100
43
  array_func: Callable,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-sgis
3
- Version: 1.0.8
3
+ Version: 1.0.9
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -34,7 +34,6 @@ Requires-Dist: joblib (>=1.4.0)
34
34
  Requires-Dist: mapclassify (>=2.5.0)
35
35
  Requires-Dist: matplotlib (>=3.7.0)
36
36
  Requires-Dist: networkx (>=3.0)
37
- Requires-Dist: numba (>=0.60.0)
38
37
  Requires-Dist: numpy (>=1.26.4)
39
38
  Requires-Dist: pandas (>=2.2.1)
40
39
  Requires-Dist: pyarrow (>=11.0.0)
@@ -6,7 +6,7 @@ sgis/geopandas_tools/bounds.py,sha256=iIIqacQafn4XrWDaJtaffLrW72z3ce_-YYwdTtWmA8
6
6
  sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=5Dy-HfLm-n4IjlLm98Wtufl4IuCw0Zglyy5VlEH0mak,19955
7
7
  sgis/geopandas_tools/centerlines.py,sha256=Q65Sx01SeAlulBEd9oaZkB2maBBNdLcJwAbTILg4SPU,11848
8
8
  sgis/geopandas_tools/cleaning.py,sha256=I3tpn5uzsLjRYi-TybUe3QuNns0CseuxkfBSmSMer0I,60208
9
- sgis/geopandas_tools/conversion.py,sha256=Cl_8tYvR0eRi26CPK2ZnIorYXJZ2vkNiDqe0VzSDVaE,25461
9
+ sgis/geopandas_tools/conversion.py,sha256=o3QJZLfaqqpJNdWWNKfQn_dS77uJxxRxWZxhf18vPXs,25505
10
10
  sgis/geopandas_tools/duplicates.py,sha256=LG8-BG8LdA2zjWauuloslIZHvMGND6Fja0MtXIPZ1wo,14301
11
11
  sgis/geopandas_tools/general.py,sha256=_XpQf792JqkvnMvEqtUMkPGVhjsct2SHSAyDYFdCyuQ,39885
12
12
  sgis/geopandas_tools/geocoding.py,sha256=n47aFQMm4yX1MsPnTM4dFjwegCA1ZmGUDj1uyu7OJV4,691
@@ -19,17 +19,17 @@ sgis/geopandas_tools/polygons_as_rings.py,sha256=BX_GZS6F9I4NbEpiOlNBd7zywJjdfdJ
19
19
  sgis/geopandas_tools/sfilter.py,sha256=SLcMYprQwnY5DNo0R7TGXk4m6u26H8o4PRn-RPhmeZY,9345
20
20
  sgis/helpers.py,sha256=3NqPfVBKlZcZTiMJrsTAlDv5tNKDHrJr_8NimutVzQg,8797
21
21
  sgis/io/_is_dapla.py,sha256=o_qFD5GOi3dsSGOKmW6R8wZU0htVwFgRbGX7ppJCqT4,431
22
- sgis/io/dapla_functions.py,sha256=8dfxBtkGUy7vltlKydXkathBsSd9DPHVIDIOe-Ctjsg,18180
23
- sgis/io/opener.py,sha256=BHyH7L8Ubh9C4Lsb8eBzGI6FLWg8UQFu-1bg3NEy_2k,862
22
+ sgis/io/dapla_functions.py,sha256=e4EYjZK2Sxt5OwxI6a8y-ye7EpjLJFbG80qAZWcfsiE,18216
23
+ sgis/io/opener.py,sha256=HWO3G1NB6bpXKM94JadCD513vjat1o1TFjWGWzyVasg,898
24
24
  sgis/io/read_parquet.py,sha256=FvZYv1rLkUlrSaUY6QW6E1yntmntTeQuZ9ZRgCDO4IM,3776
25
25
  sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  sgis/maps/examine.py,sha256=Pb0dH8JazU5E2svfQrzHO1Bi-sjy5SeyY6zoeMO34jE,9369
27
- sgis/maps/explore.py,sha256=mbSKFynLklJ3g4YfZJMDUo4K7Lg3sDoXDtnJ0l4L51w,45533
27
+ sgis/maps/explore.py,sha256=vVwqdhb-vXvmeIPvBqizVhWMmI4ICXjWsEuiuElIPCA,45864
28
28
  sgis/maps/httpserver.py,sha256=7Od9JMCtntcIQKk_TchetojMHzFHT9sPw7GANahI97c,1982
29
- sgis/maps/legend.py,sha256=1ZOhzftq1HRKlHphhfqUm82U-Kjx_xkACieLRevxke8,26232
30
- sgis/maps/map.py,sha256=4znVxefW2wVe_LSmGAVcJQxf3oF_6aAyppNo4EyYJH4,29431
29
+ sgis/maps/legend.py,sha256=lVRVCkhPmJRjGK23obFJZAO3qp6du1LYnobkkN7DPkc,26279
30
+ sgis/maps/map.py,sha256=smaf9i53EoRZWmZjn9UuqlhzUvVs1XKo2ItIpHxyuik,29592
31
31
  sgis/maps/maps.py,sha256=HbKG1OHkSFYZ2dpgpag6H-LY1tOtZKaZncNNrBQpkU4,23127
32
- sgis/maps/thematicmap.py,sha256=bFlZy2xSKmEOHhvM0d1pv8O9JuNjR3P_9colTJnduvE,20729
32
+ sgis/maps/thematicmap.py,sha256=yAE1xEfubJcDmBlOJf-Q3SVae1ZHIEMP-YB95Wy8cRw,21691
33
33
  sgis/maps/tilesources.py,sha256=F4mFHxPwkiPJdVKzNkScTX6xbJAMIUtlTq4mQ83oguw,1746
34
34
  sgis/networkanalysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  sgis/networkanalysis/_get_route.py,sha256=9I3t9pnccUPr4mozy3TJCOpGCCf3UOIojmsbifubZbA,6368
@@ -48,13 +48,13 @@ sgis/networkanalysis/traveling_salesman.py,sha256=Jjo6bHY4KJ-eK0LycyTy0sWxZjgITs
48
48
  sgis/parallel/parallel.py,sha256=SlC_mOwvSSyWTKUcxLMGkuWHUkEC6dXTlN0Jn5cAtxA,39687
49
49
  sgis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
50
  sgis/raster/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
51
- sgis/raster/base.py,sha256=Bdd30DS0iIv7fo93vrFoEBGC7a5PFaBXT46fcHwgORY,6558
52
- sgis/raster/image_collection.py,sha256=XrQddJgpP-R0KeLEWeqsOBOaMExA9lCt0_5rR7tXku8,118307
51
+ sgis/raster/base.py,sha256=tiZEuMcVK6hOm_aIjWhQ1WGshcjsxT1fFkuBSLFiMC0,7785
52
+ sgis/raster/image_collection.py,sha256=a2qpaYcLugZ4X9noFb0Ssgd4rOZi6iSqihTNKx4xQsU,120124
53
53
  sgis/raster/indices.py,sha256=-J1HYmnT240iozvgagvyis6K0_GHZHRuUrPOgyoeIrY,223
54
- sgis/raster/regex.py,sha256=I7pTAYNoOFgcPRLllR4jGMhmRk8AkOgm1D38fDSFnlg,3745
54
+ sgis/raster/regex.py,sha256=kYhVpRYzoXutx1dSYmqMoselWXww7MMEsTPmLZwHjbM,3759
55
55
  sgis/raster/sentinel_config.py,sha256=nySDqn2R8M6W8jguoBeSAK_zzbAsqmaI59i32446FwY,1268
56
- sgis/raster/zonal.py,sha256=st2mWiUcdxeEiHBOZSgFOnVcP6pc4EMPJBPw537Z4V8,3837
57
- ssb_sgis-1.0.8.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
58
- ssb_sgis-1.0.8.dist-info/METADATA,sha256=9Q_QyG0VOQAy9uhAi1kX64dVgb6AJ2xWwG91B_r_Nxo,11772
59
- ssb_sgis-1.0.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
60
- ssb_sgis-1.0.8.dist-info/RECORD,,
56
+ sgis/raster/zonal.py,sha256=D4Gyptw-yOLTCO41peIuYbY-DANsJCG19xXDlf1QAz4,2299
57
+ ssb_sgis-1.0.9.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
58
+ ssb_sgis-1.0.9.dist-info/METADATA,sha256=mf5eTre1PC3C7F_NLCDXUx61cOULgxksy1O0DY3WOh4,11740
59
+ ssb_sgis-1.0.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
60
+ ssb_sgis-1.0.9.dist-info/RECORD,,