rioxarray 0.18.2__tar.gz → 0.19.0__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.
- {rioxarray-0.18.2/rioxarray.egg-info → rioxarray-0.19.0}/PKG-INFO +4 -3
- {rioxarray-0.18.2 → rioxarray-0.19.0}/pyproject.toml +2 -2
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/merge.py +96 -71
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/raster_array.py +1 -1
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/raster_dataset.py +1 -1
- {rioxarray-0.18.2 → rioxarray-0.19.0/rioxarray.egg-info}/PKG-INFO +4 -3
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray.egg-info/requires.txt +1 -1
- {rioxarray-0.18.2 → rioxarray-0.19.0}/AUTHORS.rst +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/CONTRIBUTING.rst +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/LICENSE +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/LICENSE_datacube +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/LICENSE_xarray +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/MANIFEST.in +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/README.rst +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/__init__.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/_io.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/_options.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/_show_versions.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/crs.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/exceptions.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/py.typed +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/raster_writer.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/rioxarray.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray/xarray_plugin.py +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray.egg-info/SOURCES.txt +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray.egg-info/dependency_links.txt +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray.egg-info/entry_points.txt +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/rioxarray.egg-info/top_level.txt +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/setup.cfg +0 -0
- {rioxarray-0.18.2 → rioxarray-0.19.0}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: rioxarray
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: geospatial xarray extension powered by rasterio
|
|
5
5
|
Maintainer: rioxarray Contributors
|
|
6
6
|
License: Apache
|
|
@@ -30,7 +30,7 @@ License-File: LICENSE_datacube
|
|
|
30
30
|
License-File: LICENSE_xarray
|
|
31
31
|
License-File: AUTHORS.rst
|
|
32
32
|
Requires-Dist: packaging
|
|
33
|
-
Requires-Dist: rasterio>=1.3
|
|
33
|
+
Requires-Dist: rasterio>=1.4.3
|
|
34
34
|
Requires-Dist: xarray>=2024.7.0
|
|
35
35
|
Requires-Dist: pyproj>=3.3
|
|
36
36
|
Requires-Dist: numpy>=1.23
|
|
@@ -38,6 +38,7 @@ Provides-Extra: interp
|
|
|
38
38
|
Requires-Dist: scipy; extra == "interp"
|
|
39
39
|
Provides-Extra: all
|
|
40
40
|
Requires-Dist: scipy; extra == "all"
|
|
41
|
+
Dynamic: license-file
|
|
41
42
|
|
|
42
43
|
================
|
|
43
44
|
rioxarray README
|
|
@@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"]
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rioxarray"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.19.0"
|
|
8
8
|
description = "geospatial xarray extension powered by rasterio"
|
|
9
9
|
maintainers = [
|
|
10
10
|
{name = "rioxarray Contributors"},
|
|
@@ -35,7 +35,7 @@ classifiers = [
|
|
|
35
35
|
requires-python = ">=3.10"
|
|
36
36
|
dependencies = [
|
|
37
37
|
"packaging",
|
|
38
|
-
"rasterio>=1.3
|
|
38
|
+
"rasterio>=1.4.3",
|
|
39
39
|
"xarray>=2024.7.0",
|
|
40
40
|
"pyproj>=3.3",
|
|
41
41
|
"numpy>=1.23",
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
This module allows you to merge xarray Datasets/DataArrays
|
|
3
3
|
geospatially with the `rasterio.merge` module.
|
|
4
4
|
"""
|
|
5
|
+
|
|
5
6
|
from collections.abc import Sequence
|
|
6
7
|
from typing import Callable, Optional, Union
|
|
7
8
|
|
|
8
9
|
import numpy
|
|
9
10
|
from rasterio.crs import CRS
|
|
10
|
-
from rasterio.io import MemoryFile
|
|
11
11
|
from rasterio.merge import merge as _rio_merge
|
|
12
|
-
from xarray import DataArray, Dataset
|
|
12
|
+
from xarray import DataArray, Dataset, IndexVariable
|
|
13
13
|
|
|
14
|
-
from rioxarray.
|
|
15
|
-
from rioxarray.rioxarray import _get_nonspatial_coords
|
|
14
|
+
from rioxarray.rioxarray import _get_nonspatial_coords, _make_coords
|
|
16
15
|
|
|
17
16
|
|
|
18
17
|
class RasterioDatasetDuck:
|
|
@@ -31,29 +30,13 @@ class RasterioDatasetDuck:
|
|
|
31
30
|
self.count = int(xds.rio.count)
|
|
32
31
|
self.dtypes = [xds.dtype]
|
|
33
32
|
self.name = xds.name
|
|
34
|
-
|
|
35
|
-
self.nodatavals = [xds.rio.encoded_nodata]
|
|
36
|
-
else:
|
|
37
|
-
self.nodatavals = [xds.rio.nodata]
|
|
33
|
+
self.nodatavals = [xds.rio.nodata]
|
|
38
34
|
res = xds.rio.resolution(recalc=True)
|
|
39
35
|
self.res = (abs(res[0]), abs(res[1]))
|
|
40
36
|
self.transform = xds.rio.transform(recalc=True)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
valid_scale_factor = self._xds.encoding.get("scale_factor", 1) != 1 or any(
|
|
46
|
-
scale != 1 for scale in self._xds.encoding.get("scales", (1,))
|
|
47
|
-
)
|
|
48
|
-
valid_offset = self._xds.encoding.get("add_offset", 0.0) != 0 or any(
|
|
49
|
-
offset != 0 for offset in self._xds.encoding.get("offsets", (0,))
|
|
50
|
-
)
|
|
51
|
-
self._mask_and_scale = (
|
|
52
|
-
self._xds.rio.encoded_nodata is not None
|
|
53
|
-
or valid_scale_factor
|
|
54
|
-
or valid_offset
|
|
55
|
-
or self._xds.encoding.get("_Unsigned") is not None
|
|
56
|
-
)
|
|
37
|
+
# profile is only used for writing to a file.
|
|
38
|
+
# This never happens with rioxarray merge.
|
|
39
|
+
self.profile: dict = {}
|
|
57
40
|
|
|
58
41
|
def colormap(self, *args, **kwargs) -> None:
|
|
59
42
|
"""
|
|
@@ -63,21 +46,44 @@ class RasterioDatasetDuck:
|
|
|
63
46
|
# pylint: disable=unused-argument
|
|
64
47
|
return None
|
|
65
48
|
|
|
66
|
-
def read(self, *args, **kwargs) -> numpy.ma.MaskedArray:
|
|
49
|
+
def read(self, window, out_shape, *args, **kwargs) -> numpy.ma.MaskedArray:
|
|
50
|
+
# pylint: disable=unused-argument
|
|
67
51
|
"""
|
|
68
52
|
This method is meant to be used by the rasterio.merge.merge function.
|
|
69
53
|
"""
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
54
|
+
data_window = self._xds.rio.isel_window(window)
|
|
55
|
+
if data_window.shape != out_shape:
|
|
56
|
+
# in this section, the data is geographically the same
|
|
57
|
+
# however it is not the same dimensions as requested
|
|
58
|
+
# so need to resample to the requested shape
|
|
59
|
+
if len(out_shape) == 3:
|
|
60
|
+
_, out_height, out_width = out_shape
|
|
61
|
+
else:
|
|
62
|
+
out_height, out_width = out_shape
|
|
63
|
+
data_window = self._xds.rio.reproject(
|
|
64
|
+
self._xds.rio.crs,
|
|
65
|
+
transform=self.transform,
|
|
66
|
+
shape=(out_height, out_width),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
nodata = self.nodatavals[0]
|
|
70
|
+
mask = False
|
|
71
|
+
fill_value = None
|
|
72
|
+
if nodata is not None and numpy.isnan(nodata):
|
|
73
|
+
mask = numpy.isnan(data_window)
|
|
74
|
+
elif nodata is not None:
|
|
75
|
+
mask = data_window == nodata
|
|
76
|
+
fill_value = nodata
|
|
77
|
+
|
|
78
|
+
# make sure the returned shape matches
|
|
79
|
+
# the expected shape. This can be the case
|
|
80
|
+
# when the xarray dataset was squeezed to 2D beforehand
|
|
81
|
+
if len(out_shape) == 3 and len(data_window.shape) == 2:
|
|
82
|
+
data_window = data_window.values.reshape((1, out_height, out_width))
|
|
83
|
+
|
|
84
|
+
return numpy.ma.array(
|
|
85
|
+
data_window, mask=mask, fill_value=fill_value, dtype=self.dtypes[0]
|
|
86
|
+
)
|
|
81
87
|
|
|
82
88
|
|
|
83
89
|
def merge_arrays(
|
|
@@ -155,47 +161,66 @@ def merge_arrays(
|
|
|
155
161
|
rioduckarrays.append(RasterioDatasetDuck(dataarray))
|
|
156
162
|
|
|
157
163
|
# use rasterio to merge
|
|
164
|
+
merged_data, merged_transform = _rio_merge(
|
|
165
|
+
rioduckarrays,
|
|
166
|
+
**{key: val for key, val in input_kwargs.items() if val is not None},
|
|
167
|
+
)
|
|
158
168
|
# generate merged data array
|
|
159
169
|
representative_array = rioduckarrays[0]._xds
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
170
|
+
if parse_coordinates:
|
|
171
|
+
coords = _make_coords(
|
|
172
|
+
src_data_array=representative_array,
|
|
173
|
+
dst_affine=merged_transform,
|
|
174
|
+
dst_width=merged_data.shape[-1],
|
|
175
|
+
dst_height=merged_data.shape[-2],
|
|
165
176
|
)
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
# make sure old & new coorinate names match & dimensions are correct
|
|
174
|
-
rename_map = {}
|
|
175
|
-
original_extra_dim = representative_array.rio._check_dimensions()
|
|
176
|
-
new_extra_dim = merged_data.rio._check_dimensions()
|
|
177
|
-
# make sure the output merged data shape is 2D if the
|
|
178
|
-
# original data was 2D. this can happen if the
|
|
179
|
-
# xarray datasarray was squeezed.
|
|
180
|
-
if len(merged_data.shape) == 3 and len(representative_array.shape) == 2:
|
|
181
|
-
merged_data = merged_data.squeeze(
|
|
182
|
-
dim=new_extra_dim, drop=original_extra_dim is None
|
|
177
|
+
if (
|
|
178
|
+
representative_array.rio.x_dim != "x"
|
|
179
|
+
and "x" in coords
|
|
180
|
+
and coords["x"].ndim == 1
|
|
181
|
+
):
|
|
182
|
+
coords[representative_array.rio.x_dim] = IndexVariable(
|
|
183
|
+
representative_array.rio.x_dim, coords.pop("x")
|
|
183
184
|
)
|
|
184
|
-
new_extra_dim = merged_data.rio._check_dimensions()
|
|
185
185
|
if (
|
|
186
|
-
|
|
187
|
-
and
|
|
188
|
-
and
|
|
186
|
+
representative_array.rio.y_dim != "y"
|
|
187
|
+
and "y" in coords
|
|
188
|
+
and coords["y"].ndim == 1
|
|
189
189
|
):
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
190
|
+
coords[representative_array.rio.y_dim] = IndexVariable(
|
|
191
|
+
representative_array.rio.y_dim, coords.pop("y")
|
|
192
|
+
)
|
|
193
|
+
else:
|
|
194
|
+
coords = _get_nonspatial_coords(representative_array)
|
|
195
|
+
|
|
196
|
+
# make sure the output merged data shape is 2D if the
|
|
197
|
+
# original data was 2D. this can happen if the
|
|
198
|
+
# xarray datasarray was squeezed.
|
|
199
|
+
if len(merged_data.shape) == 3 and len(representative_array.shape) == 2:
|
|
200
|
+
merged_data = merged_data.squeeze()
|
|
201
|
+
|
|
202
|
+
xda = DataArray(
|
|
203
|
+
name=representative_array.name,
|
|
204
|
+
data=merged_data,
|
|
205
|
+
coords=coords,
|
|
206
|
+
dims=tuple(representative_array.dims),
|
|
207
|
+
attrs=representative_array.attrs,
|
|
208
|
+
)
|
|
209
|
+
xda.encoding = representative_array.encoding.copy()
|
|
210
|
+
xda.rio.write_nodata(
|
|
211
|
+
nodata if nodata is not None else representative_array.rio.nodata, inplace=True
|
|
212
|
+
)
|
|
213
|
+
xda.rio.write_crs(
|
|
214
|
+
representative_array.rio.crs,
|
|
215
|
+
grid_mapping_name=representative_array.rio.grid_mapping,
|
|
216
|
+
inplace=True,
|
|
217
|
+
)
|
|
218
|
+
xda.rio.write_transform(
|
|
219
|
+
merged_transform,
|
|
220
|
+
grid_mapping_name=representative_array.rio.grid_mapping,
|
|
221
|
+
inplace=True,
|
|
222
|
+
)
|
|
223
|
+
return xda
|
|
199
224
|
|
|
200
225
|
|
|
201
226
|
def merge_datasets(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: rioxarray
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: geospatial xarray extension powered by rasterio
|
|
5
5
|
Maintainer: rioxarray Contributors
|
|
6
6
|
License: Apache
|
|
@@ -30,7 +30,7 @@ License-File: LICENSE_datacube
|
|
|
30
30
|
License-File: LICENSE_xarray
|
|
31
31
|
License-File: AUTHORS.rst
|
|
32
32
|
Requires-Dist: packaging
|
|
33
|
-
Requires-Dist: rasterio>=1.3
|
|
33
|
+
Requires-Dist: rasterio>=1.4.3
|
|
34
34
|
Requires-Dist: xarray>=2024.7.0
|
|
35
35
|
Requires-Dist: pyproj>=3.3
|
|
36
36
|
Requires-Dist: numpy>=1.23
|
|
@@ -38,6 +38,7 @@ Provides-Extra: interp
|
|
|
38
38
|
Requires-Dist: scipy; extra == "interp"
|
|
39
39
|
Provides-Extra: all
|
|
40
40
|
Requires-Dist: scipy; extra == "all"
|
|
41
|
+
Dynamic: license-file
|
|
41
42
|
|
|
42
43
|
================
|
|
43
44
|
rioxarray README
|
|
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
|