ssb-sgis 1.1.6__tar.gz → 1.1.8__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.6 → ssb_sgis-1.1.8}/PKG-INFO +1 -1
  2. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/pyproject.toml +1 -1
  3. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/duplicates.py +2 -0
  4. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/io/dapla_functions.py +9 -10
  5. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/map.py +6 -11
  6. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/LICENSE +0 -0
  7. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/README.md +0 -0
  8. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/__init__.py +0 -0
  9. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/conf.py +0 -0
  10. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/debug_config.py +0 -0
  11. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/exceptions.py +0 -0
  12. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/__init__.py +0 -0
  13. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/bounds.py +0 -0
  14. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +0 -0
  15. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/centerlines.py +0 -0
  16. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/cleaning.py +0 -0
  17. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/conversion.py +0 -0
  18. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/general.py +0 -0
  19. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/geocoding.py +0 -0
  20. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/geometry_types.py +0 -0
  21. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/neighbors.py +0 -0
  22. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/overlay.py +0 -0
  23. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/point_operations.py +0 -0
  24. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/polygon_operations.py +0 -0
  25. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
  26. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/geopandas_tools/sfilter.py +0 -0
  27. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/helpers.py +0 -0
  28. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/io/__init__.py +0 -0
  29. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/io/_is_dapla.py +0 -0
  30. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/io/opener.py +0 -0
  31. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/io/read_parquet.py +0 -0
  32. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/__init__.py +0 -0
  33. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/examine.py +0 -0
  34. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/explore.py +0 -0
  35. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/httpserver.py +0 -0
  36. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/legend.py +0 -0
  37. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/maps.py +0 -0
  38. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/norge_i_bilder.json +0 -0
  39. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/thematicmap.py +0 -0
  40. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/tilesources.py +0 -0
  41. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/maps/wms.py +0 -0
  42. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/__init__.py +0 -0
  43. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/_get_route.py +0 -0
  44. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
  45. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/_points.py +0 -0
  46. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/_service_area.py +0 -0
  47. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/closing_network_holes.py +0 -0
  48. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/cutting_lines.py +0 -0
  49. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/directednetwork.py +0 -0
  50. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/finding_isolated_networks.py +0 -0
  51. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/network.py +0 -0
  52. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/networkanalysis.py +0 -0
  53. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/networkanalysisrules.py +0 -0
  54. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/nodes.py +0 -0
  55. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/networkanalysis/traveling_salesman.py +0 -0
  56. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/parallel/__init__.py +0 -0
  57. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/parallel/parallel.py +0 -0
  58. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/py.typed +0 -0
  59. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/raster/__init__.py +0 -0
  60. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/raster/base.py +0 -0
  61. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/raster/image_collection.py +0 -0
  62. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/raster/indices.py +0 -0
  63. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/raster/regex.py +0 -0
  64. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/src/sgis/raster/sentinel_config.py +0 -0
  65. {ssb_sgis-1.1.6 → ssb_sgis-1.1.8}/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.6
3
+ Version: 1.1.8
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.6"
3
+ version = "1.1.8"
4
4
  description = "GIS functions used at Statistics Norway."
5
5
  authors = ["Morten Letnes <morten.letnes@ssb.no>"]
6
6
  license = "MIT"
@@ -164,6 +164,8 @@ def update_geometries(
164
164
 
165
165
  copied.index = copied.index.map(index_mapper)
166
166
 
167
+ copied = make_all_singlepart(copied)
168
+
167
169
  # TODO check why polygons dissappear in rare cases. For now, just add back the missing
168
170
  dissapeared = sfilter_inverse(gdf, copied.buffer(-PRECISION))
169
171
  copied = pd.concat([copied, dissapeared])
@@ -99,12 +99,14 @@ def read_geopandas(
99
99
  **kwargs,
100
100
  )
101
101
 
102
- if (
102
+ single_eq_filter = (
103
103
  isinstance(filters, Iterable)
104
104
  and len(filters) == 1
105
105
  and ("=" in next(iter(filters)) or "==" in next(iter(filters)))
106
- ):
107
- # try to read only files in the relevant partition, because glob is slow without GCSFileSystem
106
+ )
107
+ # try to read files in subfolder path / "column=value"
108
+ # because glob is slow without GCSFileSystem from the root partition
109
+ if single_eq_filter:
108
110
  try:
109
111
  expression = "".join(next(iter(filters))).replace("==", "=")
110
112
  glob_func = _get_glob(file_system)
@@ -126,7 +128,7 @@ def read_geopandas(
126
128
  return gpd.GeoDataFrame(
127
129
  _read_partitioned_parquet(
128
130
  gcs_path,
129
- read_func=_read_geopandas,
131
+ read_func=pq.read_table,
130
132
  file_system=file_system,
131
133
  mask=mask,
132
134
  filters=filters,
@@ -143,7 +145,7 @@ def read_geopandas(
143
145
  read_func = gpd.read_file
144
146
 
145
147
  with file_system.open(gcs_path, mode="rb") as file:
146
- df = _read_geopandas(
148
+ return _read_geopandas(
147
149
  file,
148
150
  read_func=read_func,
149
151
  file_format=file_format,
@@ -151,8 +153,6 @@ def read_geopandas(
151
153
  **kwargs,
152
154
  )
153
155
 
154
- return df
155
-
156
156
 
157
157
  def _read_geopandas_from_iterable(
158
158
  paths, mask, file_system, use_threads, pandas_fallback, **kwargs
@@ -761,17 +761,16 @@ def _read_partitioned_parquet(
761
761
 
762
762
  if results:
763
763
  if all(isinstance(x, DataFrame) for x in results):
764
- results = pd.concat(results)
764
+ return pd.concat(results)
765
765
  else:
766
766
  geo_metadata = _get_geo_metadata(next(iter(child_paths)), file_system)
767
- results = _arrow_to_geopandas(
767
+ return _arrow_to_geopandas(
768
768
  pyarrow.concat_tables(
769
769
  results,
770
770
  promote_options="permissive",
771
771
  ),
772
772
  geo_metadata,
773
773
  )
774
- return results
775
774
 
776
775
  # add columns to empty DataFrame
777
776
  first_path = next(iter(child_paths + [path]))
@@ -128,6 +128,8 @@ class Map:
128
128
  categorical: Set to True to convert 'column' to string values.
129
129
  **kwargs: Arbitrary keyword arguments.
130
130
  """
131
+ self.kwargs = {}
132
+
131
133
  gdfs, column, kwargs = self._separate_args(gdfs, column, kwargs)
132
134
 
133
135
  self._column = column
@@ -175,7 +177,6 @@ class Map:
175
177
  self.labels = new_labels
176
178
 
177
179
  # pop all geometry-like items from kwargs into self._gdfs
178
- self.kwargs = {}
179
180
  i = 0
180
181
  for key, value in kwargs.items():
181
182
  try:
@@ -237,8 +238,8 @@ class Map:
237
238
  self._gdf = pd.concat(self._gdfs, ignore_index=True)
238
239
 
239
240
  self._nan_idx = self._gdf[self._column].isna()
240
- self._get_unique_values()
241
241
  self._to_categorical()
242
+ self._get_unique_values()
242
243
 
243
244
  def _to_categorical(self):
244
245
  if not (self._is_categorical and self.column is not None):
@@ -262,9 +263,9 @@ class Map:
262
263
  self._gdfs[i][self.column] = to_string_via_int(gdf[self.column])
263
264
  self._gdf[self.column] = to_string_via_int(self._gdf[self.column])
264
265
 
265
- def __getattr__(self, attr: str) -> Any:
266
- """Search for attribute in kwargs."""
267
- return self.kwargs.get(attr, super().__getattribute__(attr))
266
+ # def __getattr__(self, attr: str) -> Any:
267
+ # """Search for attribute in kwargs."""
268
+ # return self.kwargs.get(attr, super().__getattribute__(attr))
268
269
 
269
270
  def __bool__(self) -> bool:
270
271
  """True of any gdfs with more than 0 rows."""
@@ -554,12 +555,6 @@ class Map:
554
555
  )
555
556
  n = n + maybe_area + maybe_length
556
557
 
557
- if n == 0:
558
- raise ValueError(
559
- f"The column {self._column!r} is not present in any "
560
- "of the passed GeoDataFrames."
561
- )
562
-
563
558
  def _check_if_categorical(self) -> bool:
564
559
  """Quite messy this..."""
565
560
  if not self._column or not self._gdfs:
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