ssb-sgis 1.1.7__tar.gz → 1.1.9__tar.gz

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.
Files changed (65) hide show
  1. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/PKG-INFO +1 -1
  2. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/pyproject.toml +1 -1
  3. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/overlay.py +8 -5
  4. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/dapla_functions.py +15 -10
  5. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/explore.py +4 -0
  6. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/map.py +0 -4
  7. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/LICENSE +0 -0
  8. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/README.md +0 -0
  9. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/__init__.py +0 -0
  10. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/conf.py +0 -0
  11. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/debug_config.py +0 -0
  12. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/exceptions.py +0 -0
  13. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/__init__.py +0 -0
  14. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/bounds.py +0 -0
  15. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +0 -0
  16. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/centerlines.py +0 -0
  17. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/cleaning.py +0 -0
  18. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/conversion.py +0 -0
  19. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/duplicates.py +0 -0
  20. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/general.py +0 -0
  21. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/geocoding.py +0 -0
  22. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/geometry_types.py +0 -0
  23. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/neighbors.py +0 -0
  24. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/point_operations.py +0 -0
  25. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/polygon_operations.py +0 -0
  26. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
  27. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/sfilter.py +0 -0
  28. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/helpers.py +0 -0
  29. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/__init__.py +0 -0
  30. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/_is_dapla.py +0 -0
  31. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/opener.py +0 -0
  32. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/read_parquet.py +0 -0
  33. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/__init__.py +0 -0
  34. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/examine.py +0 -0
  35. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/httpserver.py +0 -0
  36. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/legend.py +0 -0
  37. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/maps.py +0 -0
  38. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/norge_i_bilder.json +0 -0
  39. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/thematicmap.py +0 -0
  40. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/tilesources.py +0 -0
  41. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/wms.py +0 -0
  42. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/__init__.py +0 -0
  43. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_get_route.py +0 -0
  44. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
  45. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_points.py +0 -0
  46. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_service_area.py +0 -0
  47. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/closing_network_holes.py +0 -0
  48. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/cutting_lines.py +0 -0
  49. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/directednetwork.py +0 -0
  50. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/finding_isolated_networks.py +0 -0
  51. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/network.py +0 -0
  52. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/networkanalysis.py +0 -0
  53. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/networkanalysisrules.py +0 -0
  54. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/nodes.py +0 -0
  55. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/traveling_salesman.py +0 -0
  56. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/parallel/__init__.py +0 -0
  57. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/parallel/parallel.py +0 -0
  58. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/py.typed +0 -0
  59. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/__init__.py +0 -0
  60. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/base.py +0 -0
  61. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/image_collection.py +0 -0
  62. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/indices.py +0 -0
  63. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/regex.py +0 -0
  64. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/sentinel_config.py +0 -0
  65. {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/zonal.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ssb-sgis
3
- Version: 1.1.7
3
+ Version: 1.1.9
4
4
  Summary: GIS functions used at Statistics Norway.
5
5
  Home-page: https://github.com/statisticsnorway/ssb-sgis
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ssb-sgis"
3
- version = "1.1.7"
3
+ version = "1.1.9"
4
4
  description = "GIS functions used at Statistics Norway."
5
5
  authors = ["Morten Letnes <morten.letnes@ssb.no>"]
6
6
  license = "MIT"
@@ -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:
@@ -128,7 +128,7 @@ def read_geopandas(
128
128
  return gpd.GeoDataFrame(
129
129
  _read_partitioned_parquet(
130
130
  gcs_path,
131
- read_func=_read_geopandas,
131
+ read_func=pq.read_table,
132
132
  file_system=file_system,
133
133
  mask=mask,
134
134
  filters=filters,
@@ -145,7 +145,7 @@ def read_geopandas(
145
145
  read_func = gpd.read_file
146
146
 
147
147
  with file_system.open(gcs_path, mode="rb") as file:
148
- df = _read_geopandas(
148
+ return _read_geopandas(
149
149
  file,
150
150
  read_func=read_func,
151
151
  file_format=file_format,
@@ -153,8 +153,6 @@ def read_geopandas(
153
153
  **kwargs,
154
154
  )
155
155
 
156
- return df
157
-
158
156
 
159
157
  def _read_geopandas_from_iterable(
160
158
  paths, mask, file_system, use_threads, pandas_fallback, **kwargs
@@ -242,8 +240,13 @@ def _get_geo_metadata(file, file_system) -> dict:
242
240
  try:
243
241
  meta = pq.read_schema(file).metadata
244
242
  except FileNotFoundError:
245
- with file_system.open(file, "rb") as f:
246
- 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
247
250
 
248
251
  return json.loads(meta[b"geo"])
249
252
 
@@ -763,21 +766,23 @@ def _read_partitioned_parquet(
763
766
 
764
767
  if results:
765
768
  if all(isinstance(x, DataFrame) for x in results):
766
- results = pd.concat(results)
769
+ return pd.concat(results)
767
770
  else:
768
771
  geo_metadata = _get_geo_metadata(next(iter(child_paths)), file_system)
769
- results = _arrow_to_geopandas(
772
+ return _arrow_to_geopandas(
770
773
  pyarrow.concat_tables(
771
774
  results,
772
775
  promote_options="permissive",
773
776
  ),
774
777
  geo_metadata,
775
778
  )
776
- return results
777
779
 
778
780
  # add columns to empty DataFrame
779
781
  first_path = next(iter(child_paths + [path]))
780
- return pd.DataFrame(columns=_get_columns(first_path, file_system))
782
+ df = pd.DataFrame(columns=_get_columns(first_path, file_system))
783
+ if "columns" in kwargs:
784
+ return df[list(kwargs["columns"])]
785
+ return df
781
786
 
782
787
 
783
788
  def paths_are_equal(path1: Path | str, path2: Path | str) -> bool:
@@ -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_())
@@ -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))
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes