ssb-sgis 1.1.14__py3-none-any.whl → 1.1.16__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.
@@ -480,7 +480,9 @@ def _dissolve_thick_double_and_update(gdf, double, thin_double):
480
480
  .pipe(update_geometries, geom_type="polygon")
481
481
  )
482
482
  return (
483
- clean_overlay(gdf, large, how="update").pipe(sort_small_first)
483
+ clean_overlay(gdf, large, how="update", geom_type="polygon").pipe(
484
+ sort_small_first
485
+ )
484
486
  # .sort_values("_poly_idx")
485
487
  .pipe(update_geometries, geom_type="polygon")
486
488
  )
@@ -601,6 +603,7 @@ def split_by_neighbors(df, split_by, tolerance, grid_size=None) -> GeoDataFrame:
601
603
  buff(df, tolerance),
602
604
  how="identity",
603
605
  grid_size=grid_size,
606
+ geom_type="polygon",
604
607
  )
605
608
  .pipe(get_line_segments)
606
609
  .reset_index(drop=True)
@@ -621,7 +624,9 @@ def split_by_neighbors(df, split_by, tolerance, grid_size=None) -> GeoDataFrame:
621
624
 
622
625
  buffered = buff(extended_lines, tolerance, single_sided=True)
623
626
 
624
- return clean_overlay(df, buffered, how="identity", grid_size=grid_size)
627
+ return clean_overlay(
628
+ df, buffered, how="identity", geom_type="polygon", grid_size=grid_size
629
+ )
625
630
 
626
631
 
627
632
  def extend_lines(arr1, arr2, distance) -> NDArray[LineString]:
@@ -205,9 +205,9 @@ def get_polygon_clusters(
205
205
 
206
206
  def get_cluster_mapper(
207
207
  gdf: GeoDataFrame | GeoSeries, predicate: str = "intersects"
208
- ) -> dict[int, int]:
209
- if not gdf.index.is_unique:
210
- raise ValueError("Index must be unique")
208
+ ) -> list[int]:
209
+ """Returns a list of cluster indices corresponding to the order of the input GeoDataFrame or GeoSeries."""
210
+ gdf = gdf.reset_index(drop=True)
211
211
  neighbors = get_neighbor_indices(gdf, gdf, predicate=predicate)
212
212
 
213
213
  edges = [(source, target) for source, target in neighbors.items()]
@@ -215,11 +215,12 @@ def get_cluster_mapper(
215
215
  graph = nx.Graph()
216
216
  graph.add_edges_from(edges)
217
217
 
218
- return {
219
- j: i
220
- for i, component in enumerate(nx.connected_components(graph))
221
- for j in component
218
+ mapper = {
219
+ i: cluster_index
220
+ for cluster_index, component in enumerate(nx.connected_components(graph))
221
+ for i in component
222
222
  }
223
+ return list(dict(sorted(mapper.items())).values())
223
224
 
224
225
 
225
226
  def eliminate_by_longest(
sgis/maps/maps.py CHANGED
@@ -164,7 +164,7 @@ def explore(
164
164
 
165
165
  mask = kwargs.pop("mask", loc_mask)
166
166
 
167
- if mask is not None:
167
+ if mask is not None and center is None:
168
168
  return clipmap(
169
169
  *gdfs,
170
170
  column=column,
@@ -897,9 +897,6 @@ class Band(_ImageBandBase):
897
897
  if self._bounds is None:
898
898
  raise ValueError("Must specify bounds when data is an array.")
899
899
  if not (res is None or (callable(res) and res() is None)):
900
- # if not (res is None or (callable(res) and res() is None)) and _res_as_tuple(
901
- # res
902
- # ) != _get_res_from_bounds(self._bounds, data.shape):
903
900
  raise ValueError(
904
901
  f"Cannot specify 'res' when data is an array. {res} and {_get_res_from_bounds(self._bounds, data.shape)}"
905
902
  )
@@ -934,10 +931,6 @@ class Band(_ImageBandBase):
934
931
 
935
932
  if self.metadata:
936
933
  parent = _fix_path(str(Path(self.path).parent))
937
- if self.path is not None:
938
- self.metadata = {
939
- key: value for key, value in self.metadata.items() if key == parent
940
- }
941
934
  for key, value in self.metadata.get(parent, {}).items():
942
935
  if key == "bands" and self.band_id in value:
943
936
  band_metadata = value[self.band_id]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-sgis
3
- Version: 1.1.14
3
+ Version: 1.1.16
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -6,7 +6,7 @@ sgis/geopandas_tools/__init__.py,sha256=bo8lFMcltOz7TtWAi52_ekR2gd3mjfBfKeMDV5zu
6
6
  sgis/geopandas_tools/bounds.py,sha256=YJyF0gp78hFAjLLZmDquRKCBAtbt7QouG3snTcJeNQs,23822
7
7
  sgis/geopandas_tools/buffer_dissolve_explode.py,sha256=t9GJqRMDsHEU74RIlqeMr4QBgbTK0hYlXL4af1RKIks,19955
8
8
  sgis/geopandas_tools/centerlines.py,sha256=Q65Sx01SeAlulBEd9oaZkB2maBBNdLcJwAbTILg4SPU,11848
9
- sgis/geopandas_tools/cleaning.py,sha256=0j7_bfuAjWVBUImbPTXuwNdYRJ_By6HAwaOdw5Dh4vc,24315
9
+ sgis/geopandas_tools/cleaning.py,sha256=PkAVVZ84ahek8_uVlTRtCO8nCWO6DdGltWLTmPOsvxM,24426
10
10
  sgis/geopandas_tools/conversion.py,sha256=o3QJZLfaqqpJNdWWNKfQn_dS77uJxxRxWZxhf18vPXs,25505
11
11
  sgis/geopandas_tools/duplicates.py,sha256=p9OCYWtwkWE7i-kZX_dRqAiczsUoWEWl5I8GeYIjQOM,14968
12
12
  sgis/geopandas_tools/general.py,sha256=UPtmgEMhTZw-qMiCCjeTtyBlJWoVE96SSanufPK8MLs,39976
@@ -15,7 +15,7 @@ sgis/geopandas_tools/geometry_types.py,sha256=ijQDbQaZPqPGjBl707H4yooNXpk21RXyat
15
15
  sgis/geopandas_tools/neighbors.py,sha256=vduQlHeoZjHyD5pxDbjfonQ3-LAHGfPETxV7-L6Sg4M,16634
16
16
  sgis/geopandas_tools/overlay.py,sha256=pMQK86t0ixKErHQsP0HC8RXHUXNxDCNdH6FK1MEJamM,25779
17
17
  sgis/geopandas_tools/point_operations.py,sha256=JM4hvfIVxZaZdGNlGzcCurrKzkgC_b9hzbFYN42f9WY,6972
18
- sgis/geopandas_tools/polygon_operations.py,sha256=LN5w1EC7ywJLmKlkk_MyIiKbaYJNp9wWPWPb0xlORLs,49923
18
+ sgis/geopandas_tools/polygon_operations.py,sha256=1XiwQHYPbd3Xj3B68YamzyT_2kdiJrrwIku4JjVa2ks,50066
19
19
  sgis/geopandas_tools/polygons_as_rings.py,sha256=BX_GZS6F9I4NbEpiOlNBd7zywJjdfdJVi_MkeONBuiM,14941
20
20
  sgis/geopandas_tools/sfilter.py,sha256=SLcMYprQwnY5DNo0R7TGXk4m6u26H8o4PRn-RPhmeZY,9345
21
21
  sgis/helpers.py,sha256=_h7ke9hJrRNhHW-ZX3gA95fOrX2s1ADKBMxc94p2F4Q,9627
@@ -30,7 +30,7 @@ sgis/maps/explore.py,sha256=0QDPaj5YU2Jps5iujuHu-vk_R9mFh_aOhbN1eU-fxcI,47898
30
30
  sgis/maps/httpserver.py,sha256=eCDoB9x74kSLiGEj2X3O91t3oscY_ia17UNuaaJ6tCc,2472
31
31
  sgis/maps/legend.py,sha256=lVRVCkhPmJRjGK23obFJZAO3qp6du1LYnobkkN7DPkc,26279
32
32
  sgis/maps/map.py,sha256=lwQUJvK3I9dPNSxPeRty9ICodz_GXQBN1OHhghI7IsE,30439
33
- sgis/maps/maps.py,sha256=gxu0rgcVygjudRtM1dVRmsUMilMUIg3vG-UgvASM91E,23072
33
+ sgis/maps/maps.py,sha256=csPXJa9R7zwlDJ0lz8qW91l0uRxjo1m2smoU8IPtgLA,23091
34
34
  sgis/maps/norge_i_bilder.json,sha256=W_mFfte3DxugWbEudZ5fadZ2JeFYb0hyab2Quf4oJME,481311
35
35
  sgis/maps/thematicmap.py,sha256=w6q4_gIr8BubQgsPJkc6WXk-tmplDLGcKyjphhFp7ng,21873
36
36
  sgis/maps/tilesources.py,sha256=F4mFHxPwkiPJdVKzNkScTX6xbJAMIUtlTq4mQ83oguw,1746
@@ -54,12 +54,12 @@ sgis/parallel/parallel.py,sha256=CzHetSAr9wvSrEDFTqDq2xAsNuG1ig22-vcEOIoUVv4,396
54
54
  sgis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  sgis/raster/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
56
  sgis/raster/base.py,sha256=tiZEuMcVK6hOm_aIjWhQ1WGshcjsxT1fFkuBSLFiMC0,7785
57
- sgis/raster/image_collection.py,sha256=qmxYGgdXN1ngSfpuOzyFKlxFG6YhqHmbd697tHaEQec,125639
57
+ sgis/raster/image_collection.py,sha256=QuqCJ1HYXiVu7c6EEO5bFDFj_4MG6qxjQu7-4BNE3nI,125269
58
58
  sgis/raster/indices.py,sha256=-J1HYmnT240iozvgagvyis6K0_GHZHRuUrPOgyoeIrY,223
59
59
  sgis/raster/regex.py,sha256=kYhVpRYzoXutx1dSYmqMoselWXww7MMEsTPmLZwHjbM,3759
60
60
  sgis/raster/sentinel_config.py,sha256=nySDqn2R8M6W8jguoBeSAK_zzbAsqmaI59i32446FwY,1268
61
61
  sgis/raster/zonal.py,sha256=D4Gyptw-yOLTCO41peIuYbY-DANsJCG19xXDlf1QAz4,2299
62
- ssb_sgis-1.1.14.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
63
- ssb_sgis-1.1.14.dist-info/METADATA,sha256=bMv_HRcZc-YOhOKnCVp-91KuVPmAEwIiQI1-UWZuQpM,11741
64
- ssb_sgis-1.1.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
- ssb_sgis-1.1.14.dist-info/RECORD,,
62
+ ssb_sgis-1.1.16.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
63
+ ssb_sgis-1.1.16.dist-info/METADATA,sha256=Ct_hJHlYMmi8paIDe0BsB5Ev1Lrj2GdXYsbAG-i1Y6g,11741
64
+ ssb_sgis-1.1.16.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
+ ssb_sgis-1.1.16.dist-info/RECORD,,