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.
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/PKG-INFO +1 -1
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/pyproject.toml +1 -1
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/overlay.py +8 -5
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/dapla_functions.py +15 -10
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/explore.py +4 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/map.py +0 -4
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/LICENSE +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/README.md +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/__init__.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/conf.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/debug_config.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/exceptions.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/__init__.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/bounds.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/buffer_dissolve_explode.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/centerlines.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/cleaning.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/conversion.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/duplicates.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/general.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/geocoding.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/geometry_types.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/neighbors.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/point_operations.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/polygon_operations.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/polygons_as_rings.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/geopandas_tools/sfilter.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/helpers.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/__init__.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/_is_dapla.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/opener.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/io/read_parquet.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/__init__.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/examine.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/httpserver.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/legend.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/maps.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/norge_i_bilder.json +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/thematicmap.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/tilesources.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/maps/wms.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/__init__.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_get_route.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_od_cost_matrix.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_points.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/_service_area.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/closing_network_holes.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/cutting_lines.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/directednetwork.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/finding_isolated_networks.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/network.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/networkanalysis.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/networkanalysisrules.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/nodes.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/networkanalysis/traveling_salesman.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/parallel/__init__.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/parallel/parallel.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/py.typed +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/__init__.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/base.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/image_collection.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/indices.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/regex.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/sentinel_config.py +0 -0
- {ssb_sgis-1.1.7 → ssb_sgis-1.1.9}/src/sgis/raster/zonal.py +0 -0
|
@@ -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
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
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=
|
|
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
|
-
|
|
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
|
-
|
|
246
|
-
|
|
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
|
-
|
|
769
|
+
return pd.concat(results)
|
|
767
770
|
else:
|
|
768
771
|
geo_metadata = _get_geo_metadata(next(iter(child_paths)), file_system)
|
|
769
|
-
|
|
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
|
-
|
|
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:
|
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|