From 61a032c57a59d6c76e6cace810d4282ac11de14b Mon Sep 17 00:00:00 2001 From: nicolasK Date: Fri, 22 Nov 2024 15:14:27 +0100 Subject: [PATCH 1/4] fix(zonal_stats) : wkt precision --- CHANGELOG.md | 6 ++++++ earthdaily/__init__.py | 2 +- earthdaily/accessor/__init__.py | 2 +- earthdaily/earthdatastore/cube_utils/_zonal.py | 7 +++++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c7869f4..da64a5f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.3.1] - UNRELEASED + +### Fixed + +- wkt geometriy has now the full precision when storing it in zonal stats. + ## [0.3.0] - 2024-11-19 ### Added diff --git a/earthdaily/__init__.py b/earthdaily/__init__.py index 43b8cc53..ed6b277d 100644 --- a/earthdaily/__init__.py +++ b/earthdaily/__init__.py @@ -7,7 +7,7 @@ # to hide warnings from rioxarray or nano seconds conversion # warnings.filterwarnings("ignore") -__version__ = "0.3.0" +__version__ = "0.3.1" def EarthDataStore( diff --git a/earthdaily/accessor/__init__.py b/earthdaily/accessor/__init__.py index a01f5b1c..c25ffa3c 100644 --- a/earthdaily/accessor/__init__.py +++ b/earthdaily/accessor/__init__.py @@ -263,7 +263,7 @@ def _auto_mapper(self): "vh": "VH", "hh": "HH", "hv": "HV", - } + } params = {} data_vars = list( diff --git a/earthdaily/earthdatastore/cube_utils/_zonal.py b/earthdaily/earthdatastore/cube_utils/_zonal.py index a7d29770..e65fb6d8 100644 --- a/earthdaily/earthdatastore/cube_utils/_zonal.py +++ b/earthdaily/earthdatastore/cube_utils/_zonal.py @@ -183,7 +183,7 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks): geoms.to_crs(input_crs) if method == "numpy": - feats, yx_pos = _rasterize(geoms, dataset, all_touched=all_touched) + feats, yx_pos = _rasterize(geoms.copy(), dataset, all_touched=all_touched) positions = [np.asarray(yx_pos[i + 1]) for i in np.arange(geoms.shape[0])] positions = [position for position in positions if position.size > 0] del yx_pos @@ -213,8 +213,11 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks): # create the WKT geom if isinstance(buffer_meters, float | int): geoms.geometry = geoms["geometry_original"] + + if geoms.crs.to_epsg() != 4326: + geoms = geoms.to_crs("EPSG:4326") geometry = xr.DataArray( - list(geoms.iloc[f - 1].to_crs("EPSG:4326").geometry.to_wkt()), + geoms.iloc[list(f-1)].geometry.apply(lambda x: x.wkt).values, dims=["feature"], coords={"feature": zs.feature.values}, ) From aa165bedc01c158e63a2fbe9cc75bd1f76495cd3 Mon Sep 17 00:00:00 2001 From: nkarasiak Date: Fri, 22 Nov 2024 14:14:50 +0000 Subject: [PATCH 2/4] style(ruff) : automatic lint/format --- earthdaily/accessor/__init__.py | 2 +- earthdaily/earthdatastore/cube_utils/_zonal.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/earthdaily/accessor/__init__.py b/earthdaily/accessor/__init__.py index c25ffa3c..a01f5b1c 100644 --- a/earthdaily/accessor/__init__.py +++ b/earthdaily/accessor/__init__.py @@ -263,7 +263,7 @@ def _auto_mapper(self): "vh": "VH", "hh": "HH", "hv": "HV", - } + } params = {} data_vars = list( diff --git a/earthdaily/earthdatastore/cube_utils/_zonal.py b/earthdaily/earthdatastore/cube_utils/_zonal.py index e65fb6d8..9c3185f2 100644 --- a/earthdaily/earthdatastore/cube_utils/_zonal.py +++ b/earthdaily/earthdatastore/cube_utils/_zonal.py @@ -213,11 +213,11 @@ def _loop_time_chunks(dataset, method, smart_load, time_chunks): # create the WKT geom if isinstance(buffer_meters, float | int): geoms.geometry = geoms["geometry_original"] - + if geoms.crs.to_epsg() != 4326: geoms = geoms.to_crs("EPSG:4326") geometry = xr.DataArray( - geoms.iloc[list(f-1)].geometry.apply(lambda x: x.wkt).values, + geoms.iloc[list(f - 1)].geometry.apply(lambda x: x.wkt).values, dims=["feature"], coords={"feature": zs.feature.values}, ) From 414b82ae890178b1a28a2d9e9899be78c8c5fc3d Mon Sep 17 00:00:00 2001 From: nicolasK Date: Fri, 22 Nov 2024 15:17:39 +0100 Subject: [PATCH 3/4] chore(changelog) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da64a5f9..7c91113f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- wkt geometriy has now the full precision when storing it in zonal stats. +- wkt geometries have now the full precision when storing it in zonal stats. ## [0.3.0] - 2024-11-19 From 3aee523c4c218927704d98def580a3dbd7b1a61d Mon Sep 17 00:00:00 2001 From: nicolasK Date: Fri, 22 Nov 2024 16:16:49 +0100 Subject: [PATCH 4/4] release(0.3.1) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c91113f..486fb89a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.3.1] - UNRELEASED +## [0.3.1] - 2024-11-22 ### Fixed