ssb-sgis 1.1.8__py3-none-any.whl → 1.1.10__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.
@@ -824,11 +824,14 @@ def make_valid_and_keep_geom_type(
824
824
  geoms = GeoSeries(geoms)
825
825
  geoms.index = range(len(geoms))
826
826
  geoms.loc[:] = make_valid(geoms.to_numpy())
827
- geoms = geoms.explode(index_parts=False).pipe(to_single_geom_type, geom_type)
828
- only_one = geoms.groupby(level=0).transform("size") == 1
829
- one_hit = geoms[only_one]
830
- many_hits = geoms[~only_one].groupby(level=0).agg(unary_union)
831
- return pd.concat([one_hit, many_hits]).sort_index()
827
+ geoms_with_correct_type = geoms.explode(index_parts=False).pipe(
828
+ to_single_geom_type, geom_type
829
+ )
830
+ only_one = geoms_with_correct_type.groupby(level=0).transform("size") == 1
831
+ one_hit = geoms_with_correct_type[only_one]
832
+ many_hits = geoms_with_correct_type[~only_one].groupby(level=0).agg(unary_union)
833
+ geoms_with_wrong_type = geoms.loc[~geoms.index.isin(geoms_with_correct_type.index)]
834
+ return pd.concat([one_hit, many_hits, geoms_with_wrong_type]).sort_index()
832
835
 
833
836
 
834
837
  def _agg_geoms(g: np.ndarray, grid_size: int | float | None = None) -> Geometry:
@@ -240,8 +240,13 @@ def _get_geo_metadata(file, file_system) -> dict:
240
240
  try:
241
241
  meta = pq.read_schema(file).metadata
242
242
  except FileNotFoundError:
243
- with file_system.open(file, "rb") as f:
244
- meta = pq.read_schema(f).metadata
243
+ try:
244
+ with file_system.open(file, "rb") as f:
245
+ meta = pq.read_schema(f).metadata
246
+ except Exception as e:
247
+ raise e.__class__(f"{file}: {e}") from e
248
+ except Exception as e:
249
+ raise e.__class__(f"{file}: {e}") from e
245
250
 
246
251
  return json.loads(meta[b"geo"])
247
252
 
@@ -774,7 +779,10 @@ def _read_partitioned_parquet(
774
779
 
775
780
  # add columns to empty DataFrame
776
781
  first_path = next(iter(child_paths + [path]))
777
- return pd.DataFrame(columns=_get_columns(first_path, file_system))
782
+ df = pd.DataFrame(columns=_get_columns(first_path, file_system))
783
+ if kwargs.get("columns"):
784
+ return df[list(kwargs["columns"])]
785
+ return df
778
786
 
779
787
 
780
788
  def paths_are_equal(path1: Path | str, path2: Path | str) -> bool:
sgis/maps/explore.py CHANGED
@@ -646,6 +646,10 @@ class Explore(Map):
646
646
  else:
647
647
  self._create_continous_map()
648
648
 
649
+ if not self.map:
650
+ print("No data, no map")
651
+ return
652
+
649
653
  if self.out_path:
650
654
  with self.file_system.open(self.out_path, "w") as f:
651
655
  f.write(self.map._repr_html_())
sgis/maps/map.py CHANGED
@@ -263,10 +263,6 @@ class Map:
263
263
  self._gdfs[i][self.column] = to_string_via_int(gdf[self.column])
264
264
  self._gdf[self.column] = to_string_via_int(self._gdf[self.column])
265
265
 
266
- # def __getattr__(self, attr: str) -> Any:
267
- # """Search for attribute in kwargs."""
268
- # return self.kwargs.get(attr, super().__getattribute__(attr))
269
-
270
266
  def __bool__(self) -> bool:
271
267
  """True of any gdfs with more than 0 rows."""
272
268
  return bool(len(self._gdfs) + len(self._gdf))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-sgis
3
- Version: 1.1.8
3
+ Version: 1.1.10
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -13,7 +13,7 @@ sgis/geopandas_tools/general.py,sha256=UPtmgEMhTZw-qMiCCjeTtyBlJWoVE96SSanufPK8M
13
13
  sgis/geopandas_tools/geocoding.py,sha256=n47aFQMm4yX1MsPnTM4dFjwegCA1ZmGUDj1uyu7OJV4,691
14
14
  sgis/geopandas_tools/geometry_types.py,sha256=ijQDbQaZPqPGjBl707H4yooNXpk21RXyatI7itnvqLk,7603
15
15
  sgis/geopandas_tools/neighbors.py,sha256=vduQlHeoZjHyD5pxDbjfonQ3-LAHGfPETxV7-L6Sg4M,16634
16
- sgis/geopandas_tools/overlay.py,sha256=pfRSvHmX7GXkJDkpMQvNgS6LTF6DirzrEZCVPSHDUBs,25582
16
+ sgis/geopandas_tools/overlay.py,sha256=pMQK86t0ixKErHQsP0HC8RXHUXNxDCNdH6FK1MEJamM,25779
17
17
  sgis/geopandas_tools/point_operations.py,sha256=JM4hvfIVxZaZdGNlGzcCurrKzkgC_b9hzbFYN42f9WY,6972
18
18
  sgis/geopandas_tools/polygon_operations.py,sha256=FJ-dXCxLHRsmp0oXsmBOFRprFFwmhrxqOPZkW2WWWQM,50088
19
19
  sgis/geopandas_tools/polygons_as_rings.py,sha256=BX_GZS6F9I4NbEpiOlNBd7zywJjdfdJVi_MkeONBuiM,14941
@@ -21,15 +21,15 @@ sgis/geopandas_tools/sfilter.py,sha256=SLcMYprQwnY5DNo0R7TGXk4m6u26H8o4PRn-RPhme
21
21
  sgis/helpers.py,sha256=_h7ke9hJrRNhHW-ZX3gA95fOrX2s1ADKBMxc94p2F4Q,9627
22
22
  sgis/io/__init__.py,sha256=uyBr20YDqB2bQttrd5q1JuGOvX32A-MSvS7Wmw5f5qg,177
23
23
  sgis/io/_is_dapla.py,sha256=wmfkSe98IrLhUg3dtXZusV6OVC8VlY1kbc5EQDf3P-Q,358
24
- sgis/io/dapla_functions.py,sha256=W7FNZErQb9j9iHRk5sui2cP2uHr136rrmRrpP2CFixc,30023
24
+ sgis/io/dapla_functions.py,sha256=Dp2oimCDY9L2_FBoAgDttqG9nd9aU06v5tXA1iB_aDc,30289
25
25
  sgis/io/opener.py,sha256=HWO3G1NB6bpXKM94JadCD513vjat1o1TFjWGWzyVasg,898
26
26
  sgis/io/read_parquet.py,sha256=FvZYv1rLkUlrSaUY6QW6E1yntmntTeQuZ9ZRgCDO4IM,3776
27
27
  sgis/maps/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  sgis/maps/examine.py,sha256=Pb0dH8JazU5E2svfQrzHO1Bi-sjy5SeyY6zoeMO34jE,9369
29
- sgis/maps/explore.py,sha256=Vdt1-vFKWkJxL-odh3rn2YlKpWw6Ew0bu8U3KURThNc,47797
29
+ sgis/maps/explore.py,sha256=ReML94ek49vkToXRK9vA_c5Zzg8O7n0GoeqyeuwaBpo,47879
30
30
  sgis/maps/httpserver.py,sha256=eCDoB9x74kSLiGEj2X3O91t3oscY_ia17UNuaaJ6tCc,2472
31
31
  sgis/maps/legend.py,sha256=lVRVCkhPmJRjGK23obFJZAO3qp6du1LYnobkkN7DPkc,26279
32
- sgis/maps/map.py,sha256=bvEQqHgdi8ZGQaKxIy1yIYVOKZ7sPIWo6zoWgo0IpwU,30570
32
+ sgis/maps/map.py,sha256=vvdWSYZN9U0pbv6-l6l5xG3HUWj09fE4qloOe9fF8L8,30403
33
33
  sgis/maps/maps.py,sha256=gxu0rgcVygjudRtM1dVRmsUMilMUIg3vG-UgvASM91E,23072
34
34
  sgis/maps/norge_i_bilder.json,sha256=W_mFfte3DxugWbEudZ5fadZ2JeFYb0hyab2Quf4oJME,481311
35
35
  sgis/maps/thematicmap.py,sha256=w6q4_gIr8BubQgsPJkc6WXk-tmplDLGcKyjphhFp7ng,21873
@@ -59,7 +59,7 @@ 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.8.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
63
- ssb_sgis-1.1.8.dist-info/METADATA,sha256=dwqSmleqbejdaqfpBPfqbVSb0W_PIIQ0adnXiK7ILV0,11740
64
- ssb_sgis-1.1.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
- ssb_sgis-1.1.8.dist-info/RECORD,,
62
+ ssb_sgis-1.1.10.dist-info/LICENSE,sha256=np3IfD5m0ZUofn_kVzDZqliozuiO6wrktw3LRPjyEiI,1073
63
+ ssb_sgis-1.1.10.dist-info/METADATA,sha256=TBZyISEqjWgban-cpg_xc0ohMB-Resq36r-1NY-s7V8,11741
64
+ ssb_sgis-1.1.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
65
+ ssb_sgis-1.1.10.dist-info/RECORD,,