ssb-sgis 1.1.14__py3-none-any.whl → 1.1.15__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.
@@ -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(
@@ -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.15
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -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
@@ -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.15.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
63
+ ssb_sgis-1.1.15.dist-info/METADATA,sha256=8cxb6fu1hpdI0vYDRV8GsJ5nLw6HH0Q6yuZZTCwL23M,11741
64
+ ssb_sgis-1.1.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
+ ssb_sgis-1.1.15.dist-info/RECORD,,