Skip to content

Commit 9fe80a7

Browse files
committed
fix projections for land cover vars
1 parent 5763606 commit 9fe80a7

4 files changed

Lines changed: 14 additions & 17 deletions

File tree

cryogrid_pytools/data/from_planetary_computer.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import pystac_client as _pystac_client
55
import planetary_computer as _planetary_computer
66
from .. import xr_raster_vector as _xrv # noqa
7+
from ..utils import drop_coords_without_dim
78
except ImportError as e:
89
missing_package = str(e).split("'")[1]
910
raise ImportError(
@@ -85,7 +86,6 @@ def get_dem_copernicus(
8586
xarray.DataArray
8687
The DEM data as an xarray DataArray with attributes.
8788
"""
88-
from ..utils import drop_coords_without_dim
8989
from .utils import check_epsg, smooth_data
9090

9191
check_epsg(epsg)
@@ -134,7 +134,7 @@ def get_esa_land_cover(bbox_WSEN: tuple, res: int = 30, epsg=32643) -> _xr.DataA
134134
A DataArray with the land cover data on the target grid. Contains
135135
attributes 'class_values', 'class_descriptions', 'class_colors' for plotting.
136136
"""
137-
from .utils import _long_string_processor, check_epsg, get_res_in_proj_units
137+
from .utils import _long_string_processor, check_epsg
138138

139139
def get_land_cover_classes(item):
140140
"""
@@ -170,9 +170,6 @@ def get_land_cover_classes(item):
170170
# make sure epsg is supported
171171
check_epsg(epsg)
172172

173-
# get the units in the projection
174-
res = get_res_in_proj_units(res, epsg, min_res=10)
175-
176173
_logger.info(
177174
f"Fetching ESA World Cover (v2.0) data from Planetary Computer (esa-worldcover @ {res}m)"
178175
)
@@ -209,6 +206,8 @@ def get_land_cover_classes(item):
209206
)
210207
)
211208

209+
da = da.pipe(drop_coords_without_dim).rio.write_crs(f"EPSG:{epsg}")
210+
212211
return da
213212

214213

@@ -268,6 +267,7 @@ def get_esri_land_cover(bbox_WSEN: tuple, res: int = 30, epsg: int = 32643):
268267
),
269268
)
270269

270+
da = da.pipe(drop_coords_without_dim).rio.write_crs(f"EPSG:{epsg}")
271271
return da
272272

273273

@@ -303,10 +303,7 @@ def get_sentinel2_data(
303303
xr.DataArray
304304
DataArray containing the fetched Sentinel-2 data.
305305
"""
306-
from ..utils import drop_coords_without_dim
307-
from .utils import (
308-
check_epsg,
309-
)
306+
from .utils import check_epsg
310307

311308
check_epsg(epsg)
312309

demo.ipynb

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "cryogrid_pytools"
7-
version = "0.3.14"
7+
version = "0.3.15"
88
description = "Tools to read in CryoGrid MATLAB data to Python and create forcing data"
99
readme = "README.md"
1010
license = "MIT"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)