rioxarray 0.16.0__tar.gz → 0.18.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.16.0 → rioxarray-0.18.0}/AUTHORS.rst +2 -0
- {rioxarray-0.16.0/rioxarray.egg-info → rioxarray-0.18.0}/PKG-INFO +3 -3
- {rioxarray-0.16.0 → rioxarray-0.18.0}/README.rst +1 -1
- {rioxarray-0.16.0 → rioxarray-0.18.0}/pyproject.toml +2 -2
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/_io.py +32 -17
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/merge.py +54 -42
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/raster_array.py +84 -36
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/raster_dataset.py +45 -16
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/raster_writer.py +33 -20
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/rioxarray.py +24 -13
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/xarray_plugin.py +1 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0/rioxarray.egg-info}/PKG-INFO +3 -3
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray.egg-info/requires.txt +1 -1
- {rioxarray-0.16.0 → rioxarray-0.18.0}/CONTRIBUTING.rst +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/LICENSE +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/LICENSE_datacube +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/LICENSE_xarray +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/MANIFEST.in +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/__init__.py +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/_options.py +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/_show_versions.py +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/crs.py +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/exceptions.py +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray/py.typed +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray.egg-info/SOURCES.txt +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray.egg-info/dependency_links.txt +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray.egg-info/entry_points.txt +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/rioxarray.egg-info/top_level.txt +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/setup.cfg +0 -0
- {rioxarray-0.16.0 → rioxarray-0.18.0}/setup.py +0 -0
|
@@ -61,6 +61,8 @@ Thanks goes to these wonderful people (`emoji key <https://allcontributors.org/d
|
|
|
61
61
|
<td align="center"><a href="https://github.com/valanm22"><img src="https://avatars.githubusercontent.com/u/84893551?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Valan Baptist Mathuranayagam</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=valanm22" title="Documentation">📖</a></td>
|
|
62
62
|
<td align="center"><a href="https://github.com/peterm790"><img src="https://avatars.githubusercontent.com/u/52179978?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Peter Marsh</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=peterm790" title="Code">💻</a> <a href="https://github.com/corteva/rioxarray/commits?author=peterm790" title="Tests">⚠️</a></td>
|
|
63
63
|
<td align="center"><a href="https://github.com/dluks"><img src="https://avatars.githubusercontent.com/u/4911680?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel Lusk</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=dluks" title="Code">💻</a> <a href="https://github.com/corteva/rioxarray/commits?author=dluks" title="Documentation">📖</a></td>
|
|
64
|
+
<td align="center"><a href="https://github.com/DahnJ"><img src="https://avatars.githubusercontent.com/u/18722560?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Daniel Jahn (dahn)</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/commits?author=DahnJ" title="Documentation">📖</a></td>
|
|
65
|
+
<td align="center"><a href="https://phofl.github.io/"><img src="https://avatars.githubusercontent.com/u/61934744?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Patrick Hoefler</b></sub></a><br /><a href="https://github.com/corteva/rioxarray/issues?q=author%3Aphofl" title="Bug reports">🐛</a></td>
|
|
64
66
|
</tr>
|
|
65
67
|
</table>
|
|
66
68
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rioxarray
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.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_xarray
|
|
|
30
30
|
License-File: AUTHORS.rst
|
|
31
31
|
Requires-Dist: packaging
|
|
32
32
|
Requires-Dist: rasterio>=1.3
|
|
33
|
-
Requires-Dist: xarray>=
|
|
33
|
+
Requires-Dist: xarray>=2024.7.0
|
|
34
34
|
Requires-Dist: pyproj>=3.3
|
|
35
35
|
Requires-Dist: numpy>=1.23
|
|
36
36
|
Provides-Extra: interp
|
|
@@ -49,7 +49,7 @@ rasterio xarray extension.
|
|
|
49
49
|
:alt: Join the chat at https://gitter.im/rioxarray/community
|
|
50
50
|
:target: https://gitter.im/rioxarray/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
|
51
51
|
|
|
52
|
-
.. image:: https://img.shields.io/badge/all_contributors-
|
|
52
|
+
.. image:: https://img.shields.io/badge/all_contributors-39-orange.svg?style=flat-square
|
|
53
53
|
:alt: All Contributors
|
|
54
54
|
:target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
|
|
55
55
|
|
|
@@ -9,7 +9,7 @@ rasterio xarray extension.
|
|
|
9
9
|
:alt: Join the chat at https://gitter.im/rioxarray/community
|
|
10
10
|
:target: https://gitter.im/rioxarray/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
|
11
11
|
|
|
12
|
-
.. image:: https://img.shields.io/badge/all_contributors-
|
|
12
|
+
.. image:: https://img.shields.io/badge/all_contributors-39-orange.svg?style=flat-square
|
|
13
13
|
:alt: All Contributors
|
|
14
14
|
:target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
|
|
15
15
|
|
|
@@ -4,7 +4,7 @@ requires = ["setuptools", "wheel"]
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rioxarray"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.18.0"
|
|
8
8
|
description = "geospatial xarray extension powered by rasterio"
|
|
9
9
|
maintainers = [
|
|
10
10
|
{name = "rioxarray Contributors"},
|
|
@@ -35,7 +35,7 @@ requires-python = ">=3.10"
|
|
|
35
35
|
dependencies = [
|
|
36
36
|
"packaging",
|
|
37
37
|
"rasterio>=1.3",
|
|
38
|
-
"xarray>=
|
|
38
|
+
"xarray>=2024.7.0",
|
|
39
39
|
"pyproj>=3.3",
|
|
40
40
|
"numpy>=1.23",
|
|
41
41
|
]
|
|
@@ -295,6 +295,7 @@ class RasterioArrayWrapper(BackendArray):
|
|
|
295
295
|
|
|
296
296
|
def __init__(
|
|
297
297
|
self,
|
|
298
|
+
*,
|
|
298
299
|
manager,
|
|
299
300
|
lock,
|
|
300
301
|
name,
|
|
@@ -327,7 +328,7 @@ class RasterioArrayWrapper(BackendArray):
|
|
|
327
328
|
)
|
|
328
329
|
if self._unsigned_dtype is not None and self._fill_value is not None:
|
|
329
330
|
self._fill_value = self._unsigned_dtype.type(self._fill_value)
|
|
330
|
-
if self._unsigned_dtype is None
|
|
331
|
+
if self._unsigned_dtype is None:
|
|
331
332
|
warnings.warn(
|
|
332
333
|
f"variable {name!r} has _Unsigned attribute but is not "
|
|
333
334
|
"of integer type. Ignoring attribute.",
|
|
@@ -512,7 +513,7 @@ def _to_numeric(value: Any) -> float:
|
|
|
512
513
|
return value
|
|
513
514
|
|
|
514
515
|
|
|
515
|
-
def _parse_tag(key: str, value: Any) -> tuple[str, Any]:
|
|
516
|
+
def _parse_tag(*, key: str, value: Any) -> tuple[str, Any]:
|
|
516
517
|
# NC_GLOBAL is appended to tags with netcdf driver and is not really needed
|
|
517
518
|
key = key.split("NC_GLOBAL#")[-1]
|
|
518
519
|
if value.startswith("{") and value.endswith("}"):
|
|
@@ -530,7 +531,7 @@ def _parse_tag(key: str, value: Any) -> tuple[str, Any]:
|
|
|
530
531
|
def _parse_tags(tags: dict) -> dict:
|
|
531
532
|
parsed_tags = {}
|
|
532
533
|
for key, value in tags.items():
|
|
533
|
-
key, value = _parse_tag(key, value)
|
|
534
|
+
key, value = _parse_tag(key=key, value=value)
|
|
534
535
|
parsed_tags[key] = value
|
|
535
536
|
return parsed_tags
|
|
536
537
|
|
|
@@ -552,7 +553,7 @@ NETCDF_DTYPE_MAP = {
|
|
|
552
553
|
}
|
|
553
554
|
|
|
554
555
|
|
|
555
|
-
def _load_netcdf_attrs(tags: dict, data_array: DataArray) -> None:
|
|
556
|
+
def _load_netcdf_attrs(*, tags: dict, data_array: DataArray) -> None:
|
|
556
557
|
"""
|
|
557
558
|
Loads the netCDF attributes into the data array
|
|
558
559
|
|
|
@@ -560,7 +561,7 @@ def _load_netcdf_attrs(tags: dict, data_array: DataArray) -> None:
|
|
|
560
561
|
- variable_name#attr_name: attr_value
|
|
561
562
|
"""
|
|
562
563
|
for key, value in tags.items():
|
|
563
|
-
key, value = _parse_tag(key, value)
|
|
564
|
+
key, value = _parse_tag(key=key, value=value)
|
|
564
565
|
key_split = key.split("#")
|
|
565
566
|
if len(key_split) != 2:
|
|
566
567
|
continue
|
|
@@ -569,7 +570,7 @@ def _load_netcdf_attrs(tags: dict, data_array: DataArray) -> None:
|
|
|
569
570
|
data_array.coords[variable_name].attrs.update({attr_name: value})
|
|
570
571
|
|
|
571
572
|
|
|
572
|
-
def _parse_netcdf_attr_array(attr: Union[NDArray, str], dtype=None) -> NDArray:
|
|
573
|
+
def _parse_netcdf_attr_array(attr: Union[NDArray, str], *, dtype=None) -> NDArray:
|
|
573
574
|
"""
|
|
574
575
|
Expected format: '{2,6}' or '[2. 6.]'
|
|
575
576
|
"""
|
|
@@ -775,7 +776,7 @@ def _pop_global_netcdf_attrs_from_vars(dataset_to_clean: Dataset) -> Dataset:
|
|
|
775
776
|
|
|
776
777
|
|
|
777
778
|
def _subdataset_groups_to_dataset(
|
|
778
|
-
dim_groups: dict[Hashable, dict[Hashable, DataArray]], global_tags: dict
|
|
779
|
+
*, dim_groups: dict[Hashable, dict[Hashable, DataArray]], global_tags: dict
|
|
779
780
|
) -> Union[Dataset, list[Dataset]]:
|
|
780
781
|
if dim_groups:
|
|
781
782
|
dataset: Union[Dataset, list[Dataset]] = []
|
|
@@ -800,6 +801,7 @@ def _subdataset_groups_to_dataset(
|
|
|
800
801
|
|
|
801
802
|
def _load_subdatasets(
|
|
802
803
|
riods: RasterioReader,
|
|
804
|
+
*,
|
|
803
805
|
group: Optional[Union[str, list[str], tuple[str, ...]]],
|
|
804
806
|
variable: Optional[Union[str, list[str], tuple[str, ...]]],
|
|
805
807
|
parse_coordinates: bool,
|
|
@@ -845,6 +847,7 @@ def _load_subdatasets(
|
|
|
845
847
|
|
|
846
848
|
def _load_bands_as_variables(
|
|
847
849
|
riods: RasterioReader,
|
|
850
|
+
*,
|
|
848
851
|
parse_coordinates: bool,
|
|
849
852
|
chunks: Optional[Union[int, tuple, dict]],
|
|
850
853
|
cache: Optional[bool],
|
|
@@ -896,6 +899,7 @@ def _load_bands_as_variables(
|
|
|
896
899
|
|
|
897
900
|
|
|
898
901
|
def _prepare_dask(
|
|
902
|
+
*,
|
|
899
903
|
result: DataArray,
|
|
900
904
|
riods: RasterioReader,
|
|
901
905
|
filename: Union[str, os.PathLike],
|
|
@@ -925,7 +929,7 @@ def _prepare_dask(
|
|
|
925
929
|
chunks=(1, "auto", "auto"),
|
|
926
930
|
shape=(riods.count, riods.height, riods.width),
|
|
927
931
|
dtype=_rasterio_to_numpy_dtype(riods.dtypes),
|
|
928
|
-
previous_chunks=
|
|
932
|
+
previous_chunks=block_shape,
|
|
929
933
|
)
|
|
930
934
|
token_filename = filename
|
|
931
935
|
if bidx is not None:
|
|
@@ -936,6 +940,7 @@ def _prepare_dask(
|
|
|
936
940
|
|
|
937
941
|
|
|
938
942
|
def _handle_encoding(
|
|
943
|
+
*,
|
|
939
944
|
result: DataArray,
|
|
940
945
|
mask_and_scale: bool,
|
|
941
946
|
masked: bool,
|
|
@@ -952,8 +957,12 @@ def _handle_encoding(
|
|
|
952
957
|
variables.pop_to(
|
|
953
958
|
result.attrs, result.encoding, "scale_factor", name=da_name
|
|
954
959
|
)
|
|
960
|
+
if "scales" in result.attrs:
|
|
961
|
+
variables.pop_to(result.attrs, result.encoding, "scales", name=da_name)
|
|
955
962
|
if "add_offset" in result.attrs:
|
|
956
963
|
variables.pop_to(result.attrs, result.encoding, "add_offset", name=da_name)
|
|
964
|
+
if "offsets" in result.attrs:
|
|
965
|
+
variables.pop_to(result.attrs, result.encoding, "offsets", name=da_name)
|
|
957
966
|
if masked:
|
|
958
967
|
if "_FillValue" in result.attrs:
|
|
959
968
|
variables.pop_to(result.attrs, result.encoding, "_FillValue", name=da_name)
|
|
@@ -991,6 +1000,7 @@ def open_rasterio(
|
|
|
991
1000
|
rasterio.vrt.WarpedVRT,
|
|
992
1001
|
SingleBandDatasetReader,
|
|
993
1002
|
],
|
|
1003
|
+
*,
|
|
994
1004
|
parse_coordinates: Optional[bool] = None,
|
|
995
1005
|
chunks: Optional[Union[int, tuple, dict]] = None,
|
|
996
1006
|
cache: Optional[bool] = None,
|
|
@@ -1010,10 +1020,7 @@ def open_rasterio(
|
|
|
1010
1020
|
|
|
1011
1021
|
This should work with any file that rasterio can open (most often:
|
|
1012
1022
|
geoTIFF). The x and y coordinates are generated automatically from the
|
|
1013
|
-
file's geoinformation
|
|
1014
|
-
`"PixelIsArea" Raster Space
|
|
1015
|
-
<http://web.archive.org/web/20160326194152/http://remotesensing.org/geotiff/spec/geotiff2.5.html#2.5.2>`_
|
|
1016
|
-
for more information).
|
|
1023
|
+
file's geoinformation and refer to the center of the pixel.
|
|
1017
1024
|
|
|
1018
1025
|
.. versionadded:: 0.13 band_as_variable
|
|
1019
1026
|
|
|
@@ -1206,7 +1213,9 @@ def open_rasterio(
|
|
|
1206
1213
|
# Get geospatial coordinates
|
|
1207
1214
|
if parse_coordinates:
|
|
1208
1215
|
coords.update(
|
|
1209
|
-
_generate_spatial_coords(
|
|
1216
|
+
_generate_spatial_coords(
|
|
1217
|
+
affine=riods.transform, width=riods.width, height=riods.height
|
|
1218
|
+
)
|
|
1210
1219
|
)
|
|
1211
1220
|
|
|
1212
1221
|
unsigned = None
|
|
@@ -1220,8 +1229,8 @@ def open_rasterio(
|
|
|
1220
1229
|
da_name = attrs.pop("NETCDF_VARNAME", default_name)
|
|
1221
1230
|
data: Any = indexing.LazilyOuterIndexedArray(
|
|
1222
1231
|
RasterioArrayWrapper(
|
|
1223
|
-
manager,
|
|
1224
|
-
lock,
|
|
1232
|
+
manager=manager,
|
|
1233
|
+
lock=lock,
|
|
1225
1234
|
name=da_name,
|
|
1226
1235
|
vrt_params=vrt_params,
|
|
1227
1236
|
masked=masked,
|
|
@@ -1241,7 +1250,7 @@ def open_rasterio(
|
|
|
1241
1250
|
result.encoding = encoding
|
|
1242
1251
|
|
|
1243
1252
|
# update attributes from NetCDF attributes
|
|
1244
|
-
_load_netcdf_attrs(riods.tags(), result)
|
|
1253
|
+
_load_netcdf_attrs(tags=riods.tags(), data_array=result)
|
|
1245
1254
|
result = _decode_datetime_cf(
|
|
1246
1255
|
result, decode_times=decode_times, decode_timedelta=decode_timedelta
|
|
1247
1256
|
)
|
|
@@ -1251,7 +1260,13 @@ def open_rasterio(
|
|
|
1251
1260
|
result.attrs["_FillValue"] = result.dtype.type(result.attrs["_FillValue"])
|
|
1252
1261
|
|
|
1253
1262
|
# handle encoding
|
|
1254
|
-
_handle_encoding(
|
|
1263
|
+
_handle_encoding(
|
|
1264
|
+
result=result,
|
|
1265
|
+
mask_and_scale=mask_and_scale,
|
|
1266
|
+
masked=masked,
|
|
1267
|
+
da_name=da_name,
|
|
1268
|
+
unsigned=unsigned,
|
|
1269
|
+
)
|
|
1255
1270
|
# Affine transformation matrix (always available)
|
|
1256
1271
|
# This describes coefficients mapping pixel coordinates to CRS
|
|
1257
1272
|
# For serialization store as tuple of 6 floats, the last row being
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
This module allows you to merge xarray Datasets/DataArrays
|
|
3
3
|
geospatially with the `rasterio.merge` module.
|
|
4
4
|
"""
|
|
5
|
-
|
|
6
5
|
from collections.abc import Sequence
|
|
7
6
|
from typing import Callable, Optional, Union
|
|
8
7
|
|
|
@@ -12,6 +11,7 @@ from rasterio.io import MemoryFile
|
|
|
12
11
|
from rasterio.merge import merge as _rio_merge
|
|
13
12
|
from xarray import DataArray, Dataset
|
|
14
13
|
|
|
14
|
+
from rioxarray._io import open_rasterio
|
|
15
15
|
from rioxarray.rioxarray import _get_nonspatial_coords, _make_coords
|
|
16
16
|
|
|
17
17
|
|
|
@@ -31,13 +31,29 @@ class RasterioDatasetDuck:
|
|
|
31
31
|
self.count = int(xds.rio.count)
|
|
32
32
|
self.dtypes = [xds.dtype]
|
|
33
33
|
self.name = xds.name
|
|
34
|
-
|
|
34
|
+
if xds.rio.encoded_nodata is not None:
|
|
35
|
+
self.nodatavals = [xds.rio.encoded_nodata]
|
|
36
|
+
else:
|
|
37
|
+
self.nodatavals = [xds.rio.nodata]
|
|
35
38
|
res = xds.rio.resolution(recalc=True)
|
|
36
39
|
self.res = (abs(res[0]), abs(res[1]))
|
|
37
40
|
self.transform = xds.rio.transform(recalc=True)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
self.profile: dict = {
|
|
42
|
+
"crs": self.crs,
|
|
43
|
+
"nodata": self.nodatavals[0],
|
|
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
|
+
)
|
|
41
57
|
|
|
42
58
|
def colormap(self, *args, **kwargs) -> None:
|
|
43
59
|
"""
|
|
@@ -54,11 +70,19 @@ class RasterioDatasetDuck:
|
|
|
54
70
|
with MemoryFile() as memfile:
|
|
55
71
|
self._xds.rio.to_raster(memfile.name)
|
|
56
72
|
with memfile.open() as dataset:
|
|
57
|
-
|
|
73
|
+
if self._mask_and_scale:
|
|
74
|
+
kwargs["masked"] = True
|
|
75
|
+
out = dataset.read(*args, **kwargs)
|
|
76
|
+
if self._mask_and_scale:
|
|
77
|
+
out = out.astype(self._xds.dtype)
|
|
78
|
+
for iii in range(self.count):
|
|
79
|
+
out[iii] = out[iii] * dataset.scales[iii] + dataset.offsets[iii]
|
|
80
|
+
return out
|
|
58
81
|
|
|
59
82
|
|
|
60
83
|
def merge_arrays(
|
|
61
84
|
dataarrays: Sequence[DataArray],
|
|
85
|
+
*,
|
|
62
86
|
bounds: Optional[tuple] = None,
|
|
63
87
|
res: Optional[tuple] = None,
|
|
64
88
|
nodata: Optional[float] = None,
|
|
@@ -131,45 +155,33 @@ def merge_arrays(
|
|
|
131
155
|
rioduckarrays.append(RasterioDatasetDuck(dataarray))
|
|
132
156
|
|
|
133
157
|
# use rasterio to merge
|
|
134
|
-
merged_data, merged_transform = _rio_merge(
|
|
135
|
-
rioduckarrays,
|
|
136
|
-
**{key: val for key, val in input_kwargs.items() if val is not None},
|
|
137
|
-
)
|
|
138
158
|
# generate merged data array
|
|
139
159
|
representative_array = rioduckarrays[0]._xds
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
merged_data.shape[-2],
|
|
160
|
+
with MemoryFile() as memfile:
|
|
161
|
+
_rio_merge(
|
|
162
|
+
rioduckarrays,
|
|
163
|
+
**{key: val for key, val in input_kwargs.items() if val is not None},
|
|
164
|
+
dst_path=memfile.name,
|
|
146
165
|
)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
attrs=representative_array.attrs,
|
|
162
|
-
)
|
|
163
|
-
xda.rio.write_nodata(
|
|
164
|
-
nodata if nodata is not None else representative_array.rio.nodata, inplace=True
|
|
165
|
-
)
|
|
166
|
-
xda.rio.write_crs(representative_array.rio.crs, inplace=True)
|
|
167
|
-
xda.rio.write_transform(merged_transform, inplace=True)
|
|
168
|
-
return xda
|
|
166
|
+
with open_rasterio( # type: ignore
|
|
167
|
+
memfile.name,
|
|
168
|
+
parse_coordinates=parse_coordinates,
|
|
169
|
+
mask_and_scale=rioduckarrays[0]._mask_and_scale,
|
|
170
|
+
) as xda:
|
|
171
|
+
xda = xda.load()
|
|
172
|
+
xda.coords.update(
|
|
173
|
+
{
|
|
174
|
+
coord: value
|
|
175
|
+
for coord, value in _get_nonspatial_coords(representative_array).items()
|
|
176
|
+
if coord not in xda.coords
|
|
177
|
+
}
|
|
178
|
+
)
|
|
179
|
+
return xda # type: ignore
|
|
169
180
|
|
|
170
181
|
|
|
171
182
|
def merge_datasets(
|
|
172
183
|
datasets: Sequence[Dataset],
|
|
184
|
+
*,
|
|
173
185
|
bounds: Optional[tuple] = None,
|
|
174
186
|
res: Optional[tuple] = None,
|
|
175
187
|
nodata: Optional[float] = None,
|
|
@@ -230,10 +242,10 @@ def merge_datasets(
|
|
|
230
242
|
xds = Dataset(
|
|
231
243
|
merged_data,
|
|
232
244
|
coords=_make_coords(
|
|
233
|
-
merged_data[data_var],
|
|
234
|
-
merged_data[data_var].rio.transform(),
|
|
235
|
-
merged_data[data_var].shape[-1],
|
|
236
|
-
merged_data[data_var].shape[-2],
|
|
245
|
+
src_data_array=merged_data[data_var],
|
|
246
|
+
dst_affine=merged_data[data_var].rio.transform(),
|
|
247
|
+
dst_width=merged_data[data_var].shape[-1],
|
|
248
|
+
dst_height=merged_data[data_var].shape[-2],
|
|
237
249
|
force_generate=True,
|
|
238
250
|
),
|
|
239
251
|
attrs=representative_ds.attrs,
|
|
@@ -9,6 +9,7 @@ datacube is licensed under the Apache License, Version 2.0:
|
|
|
9
9
|
- https://github.com/opendatacube/datacube-core/blob/1d345f08a10a13c316f81100936b0ad8b1a374eb/LICENSE # noqa: E501
|
|
10
10
|
|
|
11
11
|
"""
|
|
12
|
+
|
|
12
13
|
import copy
|
|
13
14
|
import os
|
|
14
15
|
from collections.abc import Hashable, Iterable, Mapping
|
|
@@ -47,26 +48,28 @@ from rioxarray.rioxarray import (
|
|
|
47
48
|
# Based on: https://github.com/OSGeo/gdal/blob/
|
|
48
49
|
# dee861e7c91c2da7ef8ff849947713e4d9bd115c/
|
|
49
50
|
# swig/python/gdal-utils/osgeo_utils/gdal_calc.py#L61
|
|
51
|
+
# And: https://github.com/rasterio/rasterio/blob/
|
|
52
|
+
# 9e643c3f563a679aa5400d9b1a263df97b34f9e0/rasterio/dtypes.py#L99-L112
|
|
50
53
|
_NODATA_DTYPE_MAP = {
|
|
51
54
|
1: 255, # GDT_Byte
|
|
52
55
|
2: 65535, # GDT_UInt16
|
|
53
56
|
3: -32768, # GDT_Int16
|
|
54
|
-
4:
|
|
55
|
-
5: -
|
|
56
|
-
6:
|
|
57
|
-
7:
|
|
57
|
+
4: 4294967295, # GDT_UInt32
|
|
58
|
+
5: -2147483648, # GDT_Int32
|
|
59
|
+
6: numpy.nan, # GDT_Float32
|
|
60
|
+
7: numpy.nan, # GDT_Float64
|
|
58
61
|
8: None, # GDT_CInt16
|
|
59
62
|
9: None, # GDT_CInt32
|
|
60
|
-
10:
|
|
61
|
-
11:
|
|
62
|
-
12:
|
|
63
|
-
13:
|
|
64
|
-
14:
|
|
63
|
+
10: numpy.nan, # GDT_CFloat32
|
|
64
|
+
11: numpy.nan, # GDT_CFloat64
|
|
65
|
+
12: 18446744073709551615, # GDT_UInt64
|
|
66
|
+
13: -9223372036854775808, # GDT_Int64
|
|
67
|
+
14: -128, # GDT_Int8
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
|
|
68
71
|
def _generate_attrs(
|
|
69
|
-
src_data_array: xarray.DataArray, dst_nodata: Optional[float]
|
|
72
|
+
*, src_data_array: xarray.DataArray, dst_nodata: Optional[float]
|
|
70
73
|
) -> dict[str, Any]:
|
|
71
74
|
# add original attributes
|
|
72
75
|
new_attrs = copy.deepcopy(src_data_array.attrs)
|
|
@@ -87,7 +90,7 @@ def _generate_attrs(
|
|
|
87
90
|
|
|
88
91
|
|
|
89
92
|
def _add_attrs_proj(
|
|
90
|
-
new_data_array: xarray.DataArray, src_data_array: xarray.DataArray
|
|
93
|
+
*, new_data_array: xarray.DataArray, src_data_array: xarray.DataArray
|
|
91
94
|
) -> xarray.DataArray:
|
|
92
95
|
"""Make sure attributes and projection correct"""
|
|
93
96
|
# make sure dimension information is preserved
|
|
@@ -97,7 +100,7 @@ def _add_attrs_proj(
|
|
|
97
100
|
new_data_array.rio._y_dim = src_data_array.rio.y_dim
|
|
98
101
|
|
|
99
102
|
# make sure attributes preserved
|
|
100
|
-
new_attrs = _generate_attrs(src_data_array, None)
|
|
103
|
+
new_attrs = _generate_attrs(src_data_array=src_data_array, dst_nodata=None)
|
|
101
104
|
# remove fill value if it already exists in the encoding
|
|
102
105
|
# this is for data arrays pulling the encoding from a
|
|
103
106
|
# source data array instead of being generated anew.
|
|
@@ -117,6 +120,7 @@ def _add_attrs_proj(
|
|
|
117
120
|
|
|
118
121
|
|
|
119
122
|
def _make_dst_affine(
|
|
123
|
+
*,
|
|
120
124
|
src_data_array: xarray.DataArray,
|
|
121
125
|
src_crs: rasterio.crs.CRS,
|
|
122
126
|
dst_crs: rasterio.crs.CRS,
|
|
@@ -125,7 +129,13 @@ def _make_dst_affine(
|
|
|
125
129
|
**kwargs,
|
|
126
130
|
):
|
|
127
131
|
"""Determine the affine of the new projected `xarray.DataArray`"""
|
|
128
|
-
src_bounds = ()
|
|
132
|
+
src_bounds = ()
|
|
133
|
+
if (
|
|
134
|
+
"gcps" not in kwargs
|
|
135
|
+
and "rpcs" not in kwargs
|
|
136
|
+
and "src_geoloc_array" not in kwargs
|
|
137
|
+
):
|
|
138
|
+
src_bounds = src_data_array.rio.bounds()
|
|
129
139
|
src_height, src_width = src_data_array.rio.shape
|
|
130
140
|
dst_height, dst_width = dst_shape if dst_shape is not None else (None, None)
|
|
131
141
|
# pylint: disable=isinstance-second-argument-not-valid-type
|
|
@@ -154,6 +164,7 @@ def _make_dst_affine(
|
|
|
154
164
|
|
|
155
165
|
def _clip_from_disk(
|
|
156
166
|
xds: xarray.DataArray,
|
|
167
|
+
*,
|
|
157
168
|
geometries: Iterable,
|
|
158
169
|
all_touched: bool,
|
|
159
170
|
drop: bool,
|
|
@@ -180,7 +191,12 @@ def _clip_from_disk(
|
|
|
180
191
|
cropped_ds = xarray.DataArray(
|
|
181
192
|
name=xds.name,
|
|
182
193
|
data=out_image,
|
|
183
|
-
coords=_make_coords(
|
|
194
|
+
coords=_make_coords(
|
|
195
|
+
src_data_array=xds,
|
|
196
|
+
dst_affine=out_transform,
|
|
197
|
+
dst_width=width,
|
|
198
|
+
dst_height=height,
|
|
199
|
+
),
|
|
184
200
|
dims=xds.dims,
|
|
185
201
|
attrs=xds.attrs,
|
|
186
202
|
)
|
|
@@ -192,6 +208,7 @@ def _clip_from_disk(
|
|
|
192
208
|
|
|
193
209
|
def _clip_xarray(
|
|
194
210
|
xds: xarray.DataArray,
|
|
211
|
+
*,
|
|
195
212
|
geometries: Iterable,
|
|
196
213
|
all_touched: bool,
|
|
197
214
|
drop: bool,
|
|
@@ -241,7 +258,7 @@ class RasterArray(XRasterBase):
|
|
|
241
258
|
] = None # https://github.com/corteva/rioxarray/issues/254
|
|
242
259
|
|
|
243
260
|
def set_nodata(
|
|
244
|
-
self, input_nodata: Optional[float], inplace: bool = True
|
|
261
|
+
self, input_nodata: Optional[float], *, inplace: bool = True
|
|
245
262
|
) -> xarray.DataArray:
|
|
246
263
|
"""
|
|
247
264
|
Set the nodata value for the DataArray without modifying
|
|
@@ -264,7 +281,7 @@ class RasterArray(XRasterBase):
|
|
|
264
281
|
return obj
|
|
265
282
|
|
|
266
283
|
def write_nodata(
|
|
267
|
-
self, input_nodata: Optional[float], encoded: bool = False, inplace=False
|
|
284
|
+
self, input_nodata: Optional[float], *, encoded: bool = False, inplace=False
|
|
268
285
|
) -> xarray.DataArray:
|
|
269
286
|
"""
|
|
270
287
|
Write the nodata to the DataArray in a CF compliant manner.
|
|
@@ -306,7 +323,9 @@ class RasterArray(XRasterBase):
|
|
|
306
323
|
data_obj: xarray.DataArray = self._get_obj(inplace=inplace) # type: ignore
|
|
307
324
|
input_nodata = False if input_nodata is None else input_nodata
|
|
308
325
|
if input_nodata is not False:
|
|
309
|
-
input_nodata = _ensure_nodata_dtype(
|
|
326
|
+
input_nodata = _ensure_nodata_dtype(
|
|
327
|
+
original_nodata=input_nodata, new_dtype=self._obj.dtype
|
|
328
|
+
)
|
|
310
329
|
if encoded:
|
|
311
330
|
data_obj.rio.update_encoding({"_FillValue": input_nodata}, inplace=True)
|
|
312
331
|
else:
|
|
@@ -329,7 +348,9 @@ class RasterArray(XRasterBase):
|
|
|
329
348
|
encoded_nodata = self._obj.encoding.get("_FillValue")
|
|
330
349
|
if encoded_nodata is None:
|
|
331
350
|
return None
|
|
332
|
-
return _ensure_nodata_dtype(
|
|
351
|
+
return _ensure_nodata_dtype(
|
|
352
|
+
original_nodata=encoded_nodata, new_dtype=self._obj.dtype
|
|
353
|
+
)
|
|
333
354
|
|
|
334
355
|
@property
|
|
335
356
|
def nodata(self) -> Optional[float]:
|
|
@@ -362,12 +383,15 @@ class RasterArray(XRasterBase):
|
|
|
362
383
|
self._nodata = False
|
|
363
384
|
return None
|
|
364
385
|
|
|
365
|
-
self._nodata = _ensure_nodata_dtype(
|
|
386
|
+
self._nodata = _ensure_nodata_dtype(
|
|
387
|
+
original_nodata=self._nodata, new_dtype=self._obj.dtype
|
|
388
|
+
)
|
|
366
389
|
return self._nodata
|
|
367
390
|
|
|
368
391
|
def reproject(
|
|
369
392
|
self,
|
|
370
393
|
dst_crs: Any,
|
|
394
|
+
*,
|
|
371
395
|
resolution: Optional[Union[float, tuple[float, float]]] = None,
|
|
372
396
|
shape: Optional[tuple[int, int]] = None,
|
|
373
397
|
transform: Optional[Affine] = None,
|
|
@@ -436,11 +460,20 @@ class RasterArray(XRasterBase):
|
|
|
436
460
|
if gcps:
|
|
437
461
|
kwargs.setdefault("gcps", gcps)
|
|
438
462
|
|
|
439
|
-
|
|
440
|
-
|
|
463
|
+
use_affine = (
|
|
464
|
+
"gcps" not in kwargs
|
|
465
|
+
and "rpcs" not in kwargs
|
|
466
|
+
and "src_geoloc_array" not in kwargs
|
|
467
|
+
)
|
|
468
|
+
src_affine = None if not use_affine else self.transform(recalc=True)
|
|
441
469
|
if transform is None:
|
|
442
470
|
dst_affine, dst_width, dst_height = _make_dst_affine(
|
|
443
|
-
self._obj,
|
|
471
|
+
src_data_array=self._obj,
|
|
472
|
+
src_crs=self.crs,
|
|
473
|
+
dst_crs=dst_crs,
|
|
474
|
+
dst_resolution=resolution,
|
|
475
|
+
dst_shape=shape,
|
|
476
|
+
**kwargs,
|
|
444
477
|
)
|
|
445
478
|
else:
|
|
446
479
|
dst_affine = transform
|
|
@@ -449,10 +482,9 @@ class RasterArray(XRasterBase):
|
|
|
449
482
|
else:
|
|
450
483
|
dst_height, dst_width = self.shape
|
|
451
484
|
|
|
452
|
-
dst_data = self._create_dst_data(dst_height, dst_width)
|
|
485
|
+
dst_data = self._create_dst_data(dst_height=dst_height, dst_width=dst_width)
|
|
453
486
|
|
|
454
487
|
dst_nodata = self._get_dst_nodata(nodata)
|
|
455
|
-
|
|
456
488
|
rasterio.warp.reproject(
|
|
457
489
|
source=self._obj.values,
|
|
458
490
|
destination=dst_data,
|
|
@@ -466,7 +498,7 @@ class RasterArray(XRasterBase):
|
|
|
466
498
|
**kwargs,
|
|
467
499
|
)
|
|
468
500
|
# add necessary attributes
|
|
469
|
-
new_attrs = _generate_attrs(self._obj, dst_nodata)
|
|
501
|
+
new_attrs = _generate_attrs(src_data_array=self._obj, dst_nodata=dst_nodata)
|
|
470
502
|
# make sure dimensions with coordinates renamed to x,y
|
|
471
503
|
dst_dims: list[Hashable] = []
|
|
472
504
|
for dim in self._obj.dims:
|
|
@@ -484,7 +516,7 @@ class RasterArray(XRasterBase):
|
|
|
484
516
|
dst_affine=dst_affine,
|
|
485
517
|
dst_width=dst_width,
|
|
486
518
|
dst_height=dst_height,
|
|
487
|
-
force_generate=
|
|
519
|
+
force_generate=not use_affine,
|
|
488
520
|
),
|
|
489
521
|
dims=tuple(dst_dims),
|
|
490
522
|
attrs=new_attrs,
|
|
@@ -504,7 +536,7 @@ class RasterArray(XRasterBase):
|
|
|
504
536
|
dst_nodata = default_nodata if nodata is None else nodata
|
|
505
537
|
return dst_nodata
|
|
506
538
|
|
|
507
|
-
def _create_dst_data(self, dst_height: int, dst_width: int) -> numpy.ndarray:
|
|
539
|
+
def _create_dst_data(self, *, dst_height: int, dst_width: int) -> numpy.ndarray:
|
|
508
540
|
extra_dim = self._check_dimensions()
|
|
509
541
|
if extra_dim:
|
|
510
542
|
dst_data = numpy.zeros(
|
|
@@ -518,6 +550,7 @@ class RasterArray(XRasterBase):
|
|
|
518
550
|
def reproject_match(
|
|
519
551
|
self,
|
|
520
552
|
match_data_array: Union[xarray.DataArray, xarray.Dataset],
|
|
553
|
+
*,
|
|
521
554
|
resampling: Resampling = Resampling.nearest,
|
|
522
555
|
**reproject_kwargs,
|
|
523
556
|
) -> xarray.DataArray:
|
|
@@ -583,6 +616,7 @@ class RasterArray(XRasterBase):
|
|
|
583
616
|
miny: float,
|
|
584
617
|
maxx: float,
|
|
585
618
|
maxy: float,
|
|
619
|
+
*,
|
|
586
620
|
constant_values: Union[
|
|
587
621
|
float, tuple[int, int], Mapping[Any, tuple[int, int]], None
|
|
588
622
|
] = None,
|
|
@@ -662,6 +696,7 @@ class RasterArray(XRasterBase):
|
|
|
662
696
|
miny: float,
|
|
663
697
|
maxx: float,
|
|
664
698
|
maxy: float,
|
|
699
|
+
*,
|
|
665
700
|
constant_values: Union[
|
|
666
701
|
float, tuple[int, int], Mapping[Any, tuple[int, int]], None
|
|
667
702
|
] = None,
|
|
@@ -697,10 +732,16 @@ class RasterArray(XRasterBase):
|
|
|
697
732
|
pad_maxx = maxx + abs(resolution_x) / 2.0
|
|
698
733
|
pad_maxy = maxy + abs(resolution_y) / 2.0
|
|
699
734
|
|
|
700
|
-
pd_array = self.pad_xy(
|
|
735
|
+
pd_array = self.pad_xy(
|
|
736
|
+
minx=pad_minx,
|
|
737
|
+
miny=pad_miny,
|
|
738
|
+
maxx=pad_maxx,
|
|
739
|
+
maxy=pad_maxy,
|
|
740
|
+
constant_values=constant_values,
|
|
741
|
+
)
|
|
701
742
|
|
|
702
743
|
# make sure correct attributes preserved & projection added
|
|
703
|
-
_add_attrs_proj(pd_array, self._obj)
|
|
744
|
+
_add_attrs_proj(new_data_array=pd_array, src_data_array=self._obj)
|
|
704
745
|
|
|
705
746
|
return pd_array
|
|
706
747
|
|
|
@@ -710,6 +751,7 @@ class RasterArray(XRasterBase):
|
|
|
710
751
|
miny: float,
|
|
711
752
|
maxx: float,
|
|
712
753
|
maxy: float,
|
|
754
|
+
*,
|
|
713
755
|
auto_expand: Union[bool, int] = False,
|
|
714
756
|
auto_expand_limit: int = 3,
|
|
715
757
|
crs: Optional[Any] = None,
|
|
@@ -835,13 +877,14 @@ class RasterArray(XRasterBase):
|
|
|
835
877
|
)
|
|
836
878
|
|
|
837
879
|
# make sure correct attributes preserved & projection added
|
|
838
|
-
_add_attrs_proj(cl_array, self._obj)
|
|
880
|
+
_add_attrs_proj(new_data_array=cl_array, src_data_array=self._obj)
|
|
839
881
|
return cl_array
|
|
840
882
|
|
|
841
883
|
def clip(
|
|
842
884
|
self,
|
|
843
885
|
geometries: Iterable,
|
|
844
886
|
crs: Optional[Any] = None,
|
|
887
|
+
*,
|
|
845
888
|
all_touched: bool = False,
|
|
846
889
|
drop: bool = True,
|
|
847
890
|
invert: bool = False,
|
|
@@ -933,12 +976,15 @@ class RasterArray(XRasterBase):
|
|
|
933
976
|
)
|
|
934
977
|
|
|
935
978
|
# make sure correct attributes preserved & projection added
|
|
936
|
-
_add_attrs_proj(cropped_ds, self._obj)
|
|
979
|
+
_add_attrs_proj(new_data_array=cropped_ds, src_data_array=self._obj)
|
|
937
980
|
|
|
938
981
|
return cropped_ds
|
|
939
982
|
|
|
940
983
|
def _interpolate_na(
|
|
941
|
-
self,
|
|
984
|
+
self,
|
|
985
|
+
src_data: Any,
|
|
986
|
+
*,
|
|
987
|
+
method: Literal["linear", "nearest", "cubic"] = "nearest",
|
|
942
988
|
) -> numpy.ndarray:
|
|
943
989
|
"""
|
|
944
990
|
This method uses scipy.interpolate.griddata to interpolate missing data.
|
|
@@ -1018,12 +1064,13 @@ class RasterArray(XRasterBase):
|
|
|
1018
1064
|
interp_data = []
|
|
1019
1065
|
for _, sub_xds in self._obj.groupby(extra_dim):
|
|
1020
1066
|
interp_data.append(
|
|
1021
|
-
self._interpolate_na(
|
|
1067
|
+
self._interpolate_na(
|
|
1068
|
+
sub_xds.squeeze(dim=extra_dim).values, method=method
|
|
1069
|
+
)
|
|
1022
1070
|
)
|
|
1023
1071
|
interp_data = numpy.array(interp_data) # type: ignore
|
|
1024
1072
|
else:
|
|
1025
|
-
interp_data = self._interpolate_na(self._obj.
|
|
1026
|
-
|
|
1073
|
+
interp_data = self._interpolate_na(self._obj.values, method=method) # type: ignore
|
|
1027
1074
|
interp_array = xarray.DataArray(
|
|
1028
1075
|
name=self._obj.name,
|
|
1029
1076
|
data=interp_data,
|
|
@@ -1034,13 +1081,14 @@ class RasterArray(XRasterBase):
|
|
|
1034
1081
|
interp_array.encoding = self._obj.encoding
|
|
1035
1082
|
|
|
1036
1083
|
# make sure correct attributes preserved & projection added
|
|
1037
|
-
_add_attrs_proj(interp_array, self._obj)
|
|
1084
|
+
_add_attrs_proj(new_data_array=interp_array, src_data_array=self._obj)
|
|
1038
1085
|
|
|
1039
1086
|
return interp_array
|
|
1040
1087
|
|
|
1041
1088
|
def to_raster(
|
|
1042
1089
|
self,
|
|
1043
1090
|
raster_path: Union[str, os.PathLike],
|
|
1091
|
+
*,
|
|
1044
1092
|
driver: Optional[str] = None,
|
|
1045
1093
|
dtype: Optional[Union[str, numpy.dtype]] = None,
|
|
1046
1094
|
tags: Optional[dict[str, str]] = None,
|
|
@@ -58,6 +58,7 @@ class RasterDataset(XRasterBase):
|
|
|
58
58
|
def reproject(
|
|
59
59
|
self,
|
|
60
60
|
dst_crs: Any,
|
|
61
|
+
*,
|
|
61
62
|
resolution: Optional[Union[float, tuple[float, float]]] = None,
|
|
62
63
|
shape: Optional[tuple[int, int]] = None,
|
|
63
64
|
transform: Optional[Affine] = None,
|
|
@@ -116,7 +117,7 @@ class RasterDataset(XRasterBase):
|
|
|
116
117
|
resampled_dataset = xarray.Dataset(attrs=self._obj.attrs)
|
|
117
118
|
for var in self.vars:
|
|
118
119
|
try:
|
|
119
|
-
x_dim, y_dim = _get_spatial_dims(self._obj, var)
|
|
120
|
+
x_dim, y_dim = _get_spatial_dims(self._obj, var=var)
|
|
120
121
|
resampled_dataset[var] = (
|
|
121
122
|
self._obj[var]
|
|
122
123
|
.rio.set_spatial_dims(x_dim=x_dim, y_dim=y_dim, inplace=True)
|
|
@@ -141,6 +142,7 @@ class RasterDataset(XRasterBase):
|
|
|
141
142
|
def reproject_match(
|
|
142
143
|
self,
|
|
143
144
|
match_data_array: Union[xarray.DataArray, xarray.Dataset],
|
|
145
|
+
*,
|
|
144
146
|
resampling: Resampling = Resampling.nearest,
|
|
145
147
|
**reproject_kwargs,
|
|
146
148
|
) -> xarray.Dataset:
|
|
@@ -174,7 +176,7 @@ class RasterDataset(XRasterBase):
|
|
|
174
176
|
resampled_dataset = xarray.Dataset(attrs=self._obj.attrs)
|
|
175
177
|
for var in self.vars:
|
|
176
178
|
try:
|
|
177
|
-
x_dim, y_dim = _get_spatial_dims(self._obj, var)
|
|
179
|
+
x_dim, y_dim = _get_spatial_dims(self._obj, var=var)
|
|
178
180
|
resampled_dataset[var] = (
|
|
179
181
|
self._obj[var]
|
|
180
182
|
.rio.set_spatial_dims(x_dim=x_dim, y_dim=y_dim, inplace=True)
|
|
@@ -196,6 +198,7 @@ class RasterDataset(XRasterBase):
|
|
|
196
198
|
miny: float,
|
|
197
199
|
maxx: float,
|
|
198
200
|
maxy: float,
|
|
201
|
+
*,
|
|
199
202
|
constant_values: Union[
|
|
200
203
|
float, tuple[int, int], Mapping[Any, tuple[int, int]], None
|
|
201
204
|
] = None,
|
|
@@ -229,7 +232,7 @@ class RasterDataset(XRasterBase):
|
|
|
229
232
|
padded_dataset = xarray.Dataset(attrs=self._obj.attrs)
|
|
230
233
|
for var in self.vars:
|
|
231
234
|
try:
|
|
232
|
-
x_dim, y_dim = _get_spatial_dims(self._obj, var)
|
|
235
|
+
x_dim, y_dim = _get_spatial_dims(self._obj, var=var)
|
|
233
236
|
padded_dataset[var] = (
|
|
234
237
|
self._obj[var]
|
|
235
238
|
.rio.set_spatial_dims(x_dim=x_dim, y_dim=y_dim, inplace=True)
|
|
@@ -253,6 +256,7 @@ class RasterDataset(XRasterBase):
|
|
|
253
256
|
miny: float,
|
|
254
257
|
maxx: float,
|
|
255
258
|
maxy: float,
|
|
259
|
+
*,
|
|
256
260
|
auto_expand: Union[bool, int] = False,
|
|
257
261
|
auto_expand_limit: int = 3,
|
|
258
262
|
crs: Optional[Any] = None,
|
|
@@ -294,7 +298,7 @@ class RasterDataset(XRasterBase):
|
|
|
294
298
|
clipped_dataset = xarray.Dataset(attrs=self._obj.attrs)
|
|
295
299
|
for var in self.vars:
|
|
296
300
|
try:
|
|
297
|
-
x_dim, y_dim = _get_spatial_dims(self._obj, var)
|
|
301
|
+
x_dim, y_dim = _get_spatial_dims(self._obj, var=var)
|
|
298
302
|
clipped_dataset[var] = (
|
|
299
303
|
self._obj[var]
|
|
300
304
|
.rio.set_spatial_dims(x_dim=x_dim, y_dim=y_dim, inplace=True)
|
|
@@ -323,6 +327,7 @@ class RasterDataset(XRasterBase):
|
|
|
323
327
|
self,
|
|
324
328
|
geometries: Iterable,
|
|
325
329
|
crs: Optional[Any] = None,
|
|
330
|
+
*,
|
|
326
331
|
all_touched: bool = False,
|
|
327
332
|
drop: bool = True,
|
|
328
333
|
invert: bool = False,
|
|
@@ -383,7 +388,7 @@ class RasterDataset(XRasterBase):
|
|
|
383
388
|
clipped_dataset = xarray.Dataset(attrs=self._obj.attrs)
|
|
384
389
|
for var in self.vars:
|
|
385
390
|
try:
|
|
386
|
-
x_dim, y_dim = _get_spatial_dims(self._obj, var)
|
|
391
|
+
x_dim, y_dim = _get_spatial_dims(self._obj, var=var)
|
|
387
392
|
clipped_dataset[var] = (
|
|
388
393
|
self._obj[var]
|
|
389
394
|
.rio.set_spatial_dims(x_dim=x_dim, y_dim=y_dim, inplace=True)
|
|
@@ -429,7 +434,7 @@ class RasterDataset(XRasterBase):
|
|
|
429
434
|
interpolated_dataset = xarray.Dataset(attrs=self._obj.attrs)
|
|
430
435
|
for var in self.vars:
|
|
431
436
|
try:
|
|
432
|
-
x_dim, y_dim = _get_spatial_dims(self._obj, var)
|
|
437
|
+
x_dim, y_dim = _get_spatial_dims(self._obj, var=var)
|
|
433
438
|
interpolated_dataset[var] = (
|
|
434
439
|
self._obj[var]
|
|
435
440
|
.rio.set_spatial_dims(x_dim=x_dim, y_dim=y_dim, inplace=True)
|
|
@@ -448,6 +453,7 @@ class RasterDataset(XRasterBase):
|
|
|
448
453
|
def to_raster(
|
|
449
454
|
self,
|
|
450
455
|
raster_path: Union[str, os.PathLike],
|
|
456
|
+
*,
|
|
451
457
|
driver: Optional[str] = None,
|
|
452
458
|
dtype: Optional[Union[str, numpy.dtype]] = None,
|
|
453
459
|
tags: Optional[dict[str, str]] = None,
|
|
@@ -503,35 +509,58 @@ class RasterDataset(XRasterBase):
|
|
|
503
509
|
is True. Otherwise None is returned.
|
|
504
510
|
|
|
505
511
|
"""
|
|
512
|
+
# pylint: disable=too-many-locals
|
|
506
513
|
variable_dim = f"band_{uuid4()}"
|
|
507
514
|
data_array = self._obj.to_array(dim=variable_dim)
|
|
508
515
|
# ensure raster metadata preserved
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
516
|
+
attr_scales = []
|
|
517
|
+
attr_offsets = []
|
|
518
|
+
attr_nodatavals = []
|
|
519
|
+
encoded_scales = []
|
|
520
|
+
encoded_offsets = []
|
|
521
|
+
encoded_nodatavals = []
|
|
512
522
|
band_tags = []
|
|
513
523
|
long_name = []
|
|
514
524
|
for data_var in data_array[variable_dim].values:
|
|
515
|
-
|
|
516
|
-
|
|
525
|
+
try:
|
|
526
|
+
encoded_scales.append(self._obj[data_var].encoding["scale_factor"])
|
|
527
|
+
except KeyError:
|
|
528
|
+
attr_scales.append(self._obj[data_var].attrs.get("scale_factor", 1.0))
|
|
529
|
+
try:
|
|
530
|
+
encoded_offsets.append(self._obj[data_var].encoding["add_offset"])
|
|
531
|
+
except KeyError:
|
|
532
|
+
attr_offsets.append(self._obj[data_var].attrs.get("add_offset", 0.0))
|
|
517
533
|
long_name.append(self._obj[data_var].attrs.get("long_name", data_var))
|
|
518
|
-
|
|
534
|
+
if self._obj[data_var].rio.encoded_nodata is not None:
|
|
535
|
+
encoded_nodatavals.append(self._obj[data_var].rio.encoded_nodata)
|
|
536
|
+
else:
|
|
537
|
+
attr_nodatavals.append(self._obj[data_var].rio.nodata)
|
|
519
538
|
band_tags.append(self._obj[data_var].attrs.copy())
|
|
520
|
-
|
|
521
|
-
|
|
539
|
+
if encoded_scales:
|
|
540
|
+
data_array.encoding["scales"] = encoded_scales
|
|
541
|
+
else:
|
|
542
|
+
data_array.attrs["scales"] = attr_scales
|
|
543
|
+
if encoded_offsets:
|
|
544
|
+
data_array.encoding["offsets"] = encoded_offsets
|
|
545
|
+
else:
|
|
546
|
+
data_array.attrs["offsets"] = attr_offsets
|
|
522
547
|
data_array.attrs["band_tags"] = band_tags
|
|
523
548
|
data_array.attrs["long_name"] = long_name
|
|
524
549
|
|
|
550
|
+
use_encoded_nodatavals = bool(encoded_nodatavals)
|
|
551
|
+
nodatavals = encoded_nodatavals if use_encoded_nodatavals else attr_nodatavals
|
|
525
552
|
nodata = nodatavals[0]
|
|
526
553
|
if (
|
|
527
554
|
all(nodataval == nodata for nodataval in nodatavals)
|
|
528
555
|
or numpy.isnan(nodatavals).all()
|
|
529
556
|
):
|
|
530
|
-
data_array.rio.write_nodata(
|
|
557
|
+
data_array.rio.write_nodata(
|
|
558
|
+
nodata, inplace=True, encoded=use_encoded_nodatavals
|
|
559
|
+
)
|
|
531
560
|
else:
|
|
532
561
|
raise RioXarrayError(
|
|
533
562
|
"All nodata values must be the same when exporting to raster. "
|
|
534
|
-
f"Current values: {
|
|
563
|
+
f"Current values: {attr_nodatavals}"
|
|
535
564
|
)
|
|
536
565
|
if self.crs is not None:
|
|
537
566
|
data_array.rio.write_crs(self.crs, inplace=True)
|
|
@@ -32,7 +32,7 @@ except ImportError:
|
|
|
32
32
|
# Note: transform & crs are removed in write_transform/write_crs
|
|
33
33
|
|
|
34
34
|
|
|
35
|
-
def _write_tags(raster_handle, tags):
|
|
35
|
+
def _write_tags(*, raster_handle, tags):
|
|
36
36
|
"""
|
|
37
37
|
Write tags to raster dataset
|
|
38
38
|
"""
|
|
@@ -63,7 +63,7 @@ def _write_tags(raster_handle, tags):
|
|
|
63
63
|
raster_handle.update_tags(iii + 1, **band_tag)
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
def _write_band_description(raster_handle, xarray_dataset):
|
|
66
|
+
def _write_band_description(*, raster_handle, xarray_dataset):
|
|
67
67
|
"""
|
|
68
68
|
Write band descriptions using the long name
|
|
69
69
|
"""
|
|
@@ -83,7 +83,7 @@ def _write_band_description(raster_handle, xarray_dataset):
|
|
|
83
83
|
raster_handle.set_band_description(iii + 1, band_description)
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
def _write_metatata_to_raster(raster_handle, xarray_dataset, tags):
|
|
86
|
+
def _write_metatata_to_raster(*, raster_handle, xarray_dataset, tags):
|
|
87
87
|
"""
|
|
88
88
|
Write the metadata stored in the xarray object to raster metadata
|
|
89
89
|
"""
|
|
@@ -94,26 +94,29 @@ def _write_metatata_to_raster(raster_handle, xarray_dataset, tags):
|
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
# write scales and offsets
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
except KeyError:
|
|
97
|
+
scales = tags.get("scales", xarray_dataset.encoding.get("scales"))
|
|
98
|
+
if scales is None:
|
|
100
99
|
scale_factor = tags.get(
|
|
101
100
|
"scale_factor", xarray_dataset.encoding.get("scale_factor")
|
|
102
101
|
)
|
|
103
102
|
if scale_factor is not None:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
raster_handle.
|
|
107
|
-
|
|
103
|
+
scales = (scale_factor,) * raster_handle.count
|
|
104
|
+
if scales is not None:
|
|
105
|
+
raster_handle.scales = scales
|
|
106
|
+
|
|
107
|
+
offsets = tags.get("offsets", xarray_dataset.encoding.get("offsets"))
|
|
108
|
+
if offsets is None:
|
|
108
109
|
add_offset = tags.get("add_offset", xarray_dataset.encoding.get("add_offset"))
|
|
109
110
|
if add_offset is not None:
|
|
110
|
-
|
|
111
|
+
offsets = (add_offset,) * raster_handle.count
|
|
112
|
+
if offsets is not None:
|
|
113
|
+
raster_handle.offsets = offsets
|
|
111
114
|
|
|
112
115
|
_write_tags(raster_handle=raster_handle, tags=tags)
|
|
113
116
|
_write_band_description(raster_handle=raster_handle, xarray_dataset=xarray_dataset)
|
|
114
117
|
|
|
115
118
|
|
|
116
|
-
def _ensure_nodata_dtype(original_nodata, new_dtype):
|
|
119
|
+
def _ensure_nodata_dtype(*, original_nodata, new_dtype):
|
|
117
120
|
"""
|
|
118
121
|
Convert the nodata to the new datatype and raise warning
|
|
119
122
|
if the value of the nodata value changed.
|
|
@@ -123,7 +126,11 @@ def _ensure_nodata_dtype(original_nodata, new_dtype):
|
|
|
123
126
|
if numpy.issubdtype(new_dtype, numpy.complexfloating):
|
|
124
127
|
nodata = original_nodata
|
|
125
128
|
else:
|
|
126
|
-
original_nodata =
|
|
129
|
+
original_nodata = (
|
|
130
|
+
float(original_nodata)
|
|
131
|
+
if not numpy.issubdtype(type(original_nodata), numpy.integer)
|
|
132
|
+
else original_nodata
|
|
133
|
+
)
|
|
127
134
|
failure_message = (
|
|
128
135
|
f"Unable to convert nodata value ({original_nodata}) to "
|
|
129
136
|
f"new dtype ({new_dtype})."
|
|
@@ -137,7 +144,7 @@ def _ensure_nodata_dtype(original_nodata, new_dtype):
|
|
|
137
144
|
return nodata
|
|
138
145
|
|
|
139
146
|
|
|
140
|
-
def _get_dtypes(rasterio_dtype, encoded_rasterio_dtype, dataarray_dtype):
|
|
147
|
+
def _get_dtypes(*, rasterio_dtype, encoded_rasterio_dtype, dataarray_dtype):
|
|
141
148
|
"""
|
|
142
149
|
Determines the rasterio dtype and numpy dtypes based on
|
|
143
150
|
the rasterio dtype and the encoded rasterio dtype.
|
|
@@ -219,7 +226,7 @@ class RasterioWriter:
|
|
|
219
226
|
with rasterio.open(self.raster_path, "r+") as rds:
|
|
220
227
|
rds.write(item, window=Window(chx_off, chy_off, chx, chy), indexes=indexes)
|
|
221
228
|
|
|
222
|
-
def to_raster(self, xarray_dataarray, tags, windowed, lock, compute, **kwargs):
|
|
229
|
+
def to_raster(self, *, xarray_dataarray, tags, windowed, lock, compute, **kwargs):
|
|
223
230
|
"""
|
|
224
231
|
This method writes to the raster on disk.
|
|
225
232
|
|
|
@@ -248,9 +255,11 @@ class RasterioWriter:
|
|
|
248
255
|
"""
|
|
249
256
|
xarray_dataarray = xarray_dataarray.copy()
|
|
250
257
|
kwargs["dtype"], numpy_dtype = _get_dtypes(
|
|
251
|
-
kwargs["dtype"],
|
|
252
|
-
xarray_dataarray.encoding.get("rasterio_dtype"),
|
|
253
|
-
xarray_dataarray.encoding.get(
|
|
258
|
+
rasterio_dtype=kwargs["dtype"],
|
|
259
|
+
encoded_rasterio_dtype=xarray_dataarray.encoding.get("rasterio_dtype"),
|
|
260
|
+
dataarray_dtype=xarray_dataarray.encoding.get(
|
|
261
|
+
"dtype", str(xarray_dataarray.dtype)
|
|
262
|
+
),
|
|
254
263
|
)
|
|
255
264
|
# there is no equivalent for netCDF _Unsigned
|
|
256
265
|
# across output GDAL formats. It is safest to convert beforehand.
|
|
@@ -270,10 +279,14 @@ class RasterioWriter:
|
|
|
270
279
|
# Ensure dtype of output data matches the expected dtype.
|
|
271
280
|
# This check is added here as the dtype of the data is
|
|
272
281
|
# converted right before writing.
|
|
273
|
-
kwargs["nodata"] = _ensure_nodata_dtype(
|
|
282
|
+
kwargs["nodata"] = _ensure_nodata_dtype(
|
|
283
|
+
original_nodata=kwargs["nodata"], new_dtype=numpy_dtype
|
|
284
|
+
)
|
|
274
285
|
|
|
275
286
|
with rasterio.open(self.raster_path, "w", **kwargs) as rds:
|
|
276
|
-
_write_metatata_to_raster(
|
|
287
|
+
_write_metatata_to_raster(
|
|
288
|
+
raster_handle=rds, xarray_dataset=xarray_dataarray, tags=tags
|
|
289
|
+
)
|
|
277
290
|
if not (lock and is_dask_collection(xarray_dataarray.data)):
|
|
278
291
|
# write data to raster immmediately if not dask array
|
|
279
292
|
if windowed:
|
|
@@ -83,7 +83,7 @@ def _resolution(affine: Affine) -> tuple[float, float]:
|
|
|
83
83
|
|
|
84
84
|
|
|
85
85
|
def affine_to_coords(
|
|
86
|
-
affine: Affine, width: int, height: int, x_dim: str = "x", y_dim: str = "y"
|
|
86
|
+
affine: Affine, width: int, height: int, *, x_dim: str = "x", y_dim: str = "y"
|
|
87
87
|
) -> dict[str, numpy.ndarray]:
|
|
88
88
|
"""Generate 1d pixel centered coordinates from affine.
|
|
89
89
|
|
|
@@ -120,7 +120,7 @@ def affine_to_coords(
|
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
def _generate_spatial_coords(
|
|
123
|
-
affine: Affine, width: int, height: int
|
|
123
|
+
*, affine: Affine, width: int, height: int
|
|
124
124
|
) -> dict[Hashable, Any]:
|
|
125
125
|
"""get spatial coords in new transform"""
|
|
126
126
|
new_spatial_coords = affine_to_coords(affine, width, height)
|
|
@@ -162,6 +162,7 @@ def _get_nonspatial_coords(
|
|
|
162
162
|
|
|
163
163
|
|
|
164
164
|
def _make_coords(
|
|
165
|
+
*,
|
|
165
166
|
src_data_array: Union[xarray.DataArray, xarray.Dataset],
|
|
166
167
|
dst_affine: Affine,
|
|
167
168
|
dst_width: int,
|
|
@@ -178,7 +179,9 @@ def _make_coords(
|
|
|
178
179
|
)
|
|
179
180
|
or ("xc" in src_data_array.coords and "yc" in src_data_array.coords)
|
|
180
181
|
):
|
|
181
|
-
new_coords = _generate_spatial_coords(
|
|
182
|
+
new_coords = _generate_spatial_coords(
|
|
183
|
+
affine=dst_affine, width=dst_width, height=dst_height
|
|
184
|
+
)
|
|
182
185
|
new_coords.update(coords)
|
|
183
186
|
return new_coords
|
|
184
187
|
return coords
|
|
@@ -195,7 +198,7 @@ def _get_data_var_message(obj: Union[xarray.DataArray, xarray.Dataset]) -> str:
|
|
|
195
198
|
|
|
196
199
|
|
|
197
200
|
def _get_spatial_dims(
|
|
198
|
-
obj: Union[xarray.Dataset, xarray.DataArray], var: Union[Any, Hashable]
|
|
201
|
+
obj: Union[xarray.Dataset, xarray.DataArray], *, var: Union[Any, Hashable]
|
|
199
202
|
) -> tuple[str, str]:
|
|
200
203
|
"""
|
|
201
204
|
Retrieve the spatial dimensions of the dataset
|
|
@@ -213,20 +216,21 @@ def _get_spatial_dims(
|
|
|
213
216
|
|
|
214
217
|
|
|
215
218
|
def _has_spatial_dims(
|
|
216
|
-
obj: Union[xarray.Dataset, xarray.DataArray], var: Union[Any, Hashable]
|
|
219
|
+
obj: Union[xarray.Dataset, xarray.DataArray], *, var: Union[Any, Hashable]
|
|
217
220
|
) -> bool:
|
|
218
221
|
"""
|
|
219
222
|
Check to see if the variable in the Dataset has spatial dimensions
|
|
220
223
|
"""
|
|
221
224
|
try:
|
|
222
225
|
# pylint: disable=pointless-statement
|
|
223
|
-
_get_spatial_dims(obj, var)
|
|
226
|
+
_get_spatial_dims(obj, var=var)
|
|
224
227
|
except MissingSpatialDimensionError:
|
|
225
228
|
return False
|
|
226
229
|
return True
|
|
227
230
|
|
|
228
231
|
|
|
229
232
|
def _order_bounds(
|
|
233
|
+
*,
|
|
230
234
|
minx: float,
|
|
231
235
|
miny: float,
|
|
232
236
|
maxx: float,
|
|
@@ -425,7 +429,7 @@ class XRasterBase:
|
|
|
425
429
|
if hasattr(self._obj, "data_vars"):
|
|
426
430
|
grid_mappings = set()
|
|
427
431
|
for var in self._obj.data_vars:
|
|
428
|
-
if not _has_spatial_dims(self._obj, var):
|
|
432
|
+
if not _has_spatial_dims(self._obj, var=var):
|
|
429
433
|
continue
|
|
430
434
|
var_grid_mapping = self._obj[var].encoding.get(
|
|
431
435
|
"grid_mapping", self._obj[var].attrs.get("grid_mapping")
|
|
@@ -459,7 +463,7 @@ class XRasterBase:
|
|
|
459
463
|
if hasattr(data_obj, "data_vars"):
|
|
460
464
|
for var in data_obj.data_vars:
|
|
461
465
|
try:
|
|
462
|
-
x_dim, y_dim = _get_spatial_dims(data_obj, var)
|
|
466
|
+
x_dim, y_dim = _get_spatial_dims(data_obj, var=var)
|
|
463
467
|
except MissingSpatialDimensionError:
|
|
464
468
|
continue
|
|
465
469
|
# remove grid_mapping from attributes if it exists
|
|
@@ -1088,7 +1092,7 @@ class XRasterBase:
|
|
|
1088
1092
|
|
|
1089
1093
|
return left, bottom, right, top
|
|
1090
1094
|
|
|
1091
|
-
def bounds(self, recalc: bool = False) -> tuple[float, float, float, float]:
|
|
1095
|
+
def bounds(self, *, recalc: bool = False) -> tuple[float, float, float, float]:
|
|
1092
1096
|
"""
|
|
1093
1097
|
Parameters
|
|
1094
1098
|
----------
|
|
@@ -1101,13 +1105,19 @@ class XRasterBase:
|
|
|
1101
1105
|
left, bottom, right, top: float
|
|
1102
1106
|
Outermost coordinates of the `xarray.DataArray` | `xarray.Dataset`.
|
|
1103
1107
|
"""
|
|
1108
|
+
minx, miny, maxx, maxy = self._unordered_bounds(recalc=recalc)
|
|
1109
|
+
resolution_x, resolution_y = self.resolution(recalc=recalc)
|
|
1104
1110
|
return _order_bounds(
|
|
1105
|
-
|
|
1106
|
-
|
|
1111
|
+
minx=minx,
|
|
1112
|
+
miny=miny,
|
|
1113
|
+
maxx=maxx,
|
|
1114
|
+
maxy=maxy,
|
|
1115
|
+
resolution_x=resolution_x,
|
|
1116
|
+
resolution_y=resolution_y,
|
|
1107
1117
|
)
|
|
1108
1118
|
|
|
1109
1119
|
def isel_window(
|
|
1110
|
-
self, window: rasterio.windows.Window, pad: bool = False
|
|
1120
|
+
self, window: rasterio.windows.Window, *, pad: bool = False
|
|
1111
1121
|
) -> Union[xarray.Dataset, xarray.DataArray]:
|
|
1112
1122
|
"""
|
|
1113
1123
|
Use a rasterio.windows.Window to select a subset of the data.
|
|
@@ -1204,7 +1214,7 @@ class XRasterBase:
|
|
|
1204
1214
|
return subset
|
|
1205
1215
|
|
|
1206
1216
|
def transform_bounds(
|
|
1207
|
-
self, dst_crs: Any, densify_pts: int = 21, recalc: bool = False
|
|
1217
|
+
self, dst_crs: Any, *, densify_pts: int = 21, recalc: bool = False
|
|
1208
1218
|
) -> tuple[float, float, float, float]:
|
|
1209
1219
|
"""Transform bounds from src_crs to dst_crs.
|
|
1210
1220
|
|
|
@@ -1238,6 +1248,7 @@ class XRasterBase:
|
|
|
1238
1248
|
self,
|
|
1239
1249
|
gcps: Iterable[GroundControlPoint],
|
|
1240
1250
|
gcp_crs: Any,
|
|
1251
|
+
*,
|
|
1241
1252
|
grid_mapping_name: Optional[str] = None,
|
|
1242
1253
|
inplace: bool = False,
|
|
1243
1254
|
) -> Union[xarray.Dataset, xarray.DataArray]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rioxarray
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.18.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_xarray
|
|
|
30
30
|
License-File: AUTHORS.rst
|
|
31
31
|
Requires-Dist: packaging
|
|
32
32
|
Requires-Dist: rasterio>=1.3
|
|
33
|
-
Requires-Dist: xarray>=
|
|
33
|
+
Requires-Dist: xarray>=2024.7.0
|
|
34
34
|
Requires-Dist: pyproj>=3.3
|
|
35
35
|
Requires-Dist: numpy>=1.23
|
|
36
36
|
Provides-Extra: interp
|
|
@@ -49,7 +49,7 @@ rasterio xarray extension.
|
|
|
49
49
|
:alt: Join the chat at https://gitter.im/rioxarray/community
|
|
50
50
|
:target: https://gitter.im/rioxarray/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
|
51
51
|
|
|
52
|
-
.. image:: https://img.shields.io/badge/all_contributors-
|
|
52
|
+
.. image:: https://img.shields.io/badge/all_contributors-39-orange.svg?style=flat-square
|
|
53
53
|
:alt: All Contributors
|
|
54
54
|
:target: https://github.com/corteva/rioxarray/blob/master/AUTHORS.rst
|
|
55
55
|
|
|
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
|