Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ __pycache__/
*.egg-info/
build/
data/
.venv/
.venv/
**/tmp/*
15 changes: 9 additions & 6 deletions src/gregor/disaggregate.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from warnings import warn

import dask.array as da
import geopandas as gpd
import numpy as np
Expand Down Expand Up @@ -38,8 +40,9 @@ def disaggregate_polygon_to_raster(
_proxy = proxy
elif isinstance(proxy, xr.Dataset):
if len(proxy.data_vars) == 1:
raise DeprecationWarning(
"Passing DataSet is deprecated and will be disallowed in the future. Use DataArray instead."
warn(
"Passing DataSet is deprecated and will be disallowed in the future. Use DataArray instead.",
category=DeprecationWarning,
)
var_name = next(iter(proxy.data_vars))
_proxy = proxy[var_name]
Expand All @@ -62,7 +65,7 @@ def disaggregate_polygon_to_raster(

# make sure that crs of data and proxy match
if _proxy.rio.crs != _data.crs:
print(
warn(
f"CRS of `data` ({_data.crs}) does not match CRS of `proxy` ({_proxy.rio.crs}). Reprojecting CRS of `data` to match `proxy`'s CRS."
)
_data = _data.to_crs(_proxy.rio.crs)
Expand Down Expand Up @@ -111,7 +114,7 @@ def lookup_func(blk):
)

if to_data_crs and _proxy.rio.crs != data.crs:
print(f"Reprojecting results to `data`'s CRS {data.crs}.")
warn(f"Reprojecting results to `data`'s CRS {data.crs}.")
raster = raster.rio.reproject(data.crs)

return raster
Expand Down Expand Up @@ -217,7 +220,7 @@ def disaggregate_polygon_to_point(

# compare crs. If not the same, project data to proxy's crs
if not proxy.crs == _data.crs:
print(
warn(
f"CRS of `proxy` ({proxy.crs}) does not match CRS of `data` ({_data.crs}). Reprojecting CRS of `data` to `proxy`'s CRS."
)
_data = _data.to_crs(proxy.crs)
Expand Down Expand Up @@ -255,7 +258,7 @@ def disaggregate_polygon_to_point(
points = points[["geometry", "disaggregated"]]

if to_data_crs:
print(f"Reprojecting results to `data`'s CRS {_data.crs}.")
warn(f"Reprojecting results to `data`'s CRS {_data.crs}.")
points = points.to_crs(_data.crs)

return points
Loading