diff --git a/latest/.doctrees/environment.pickle b/latest/.doctrees/environment.pickle index bf4cfc6a..c6768c40 100644 Binary files a/latest/.doctrees/environment.pickle and b/latest/.doctrees/environment.pickle differ diff --git a/latest/.doctrees/examples/dask_read_write.doctree b/latest/.doctrees/examples/dask_read_write.doctree index 5a6a186a..ecca08ff 100644 Binary files a/latest/.doctrees/examples/dask_read_write.doctree and b/latest/.doctrees/examples/dask_read_write.doctree differ diff --git a/latest/.doctrees/history.doctree b/latest/.doctrees/history.doctree index 321fe91d..29c202d1 100644 Binary files a/latest/.doctrees/history.doctree and b/latest/.doctrees/history.doctree differ diff --git a/latest/_modules/index.html b/latest/_modules/index.html index 291abe2a..141800a1 100644 --- a/latest/_modules/index.html +++ b/latest/_modules/index.html @@ -6,7 +6,7 @@
Source file: https://github.com/pydata/xarray/blob/1d7bcbdc75b6d556c04e2c7d7a042e4379e15303/xarray/backends/rasterio_.py # noqa
"""
# pylint: disable=too-many-lines
-import contextlib
-import importlib.metadata
-import os
-import re
-import threading
-import warnings
-from collections import defaultdict
-from collections.abc import Hashable, Iterable
-from typing import Any, Optional, Union
-
-import numpy
-import rasterio
-from numpy.typing import NDArray
-from packaging import version
-from rasterio.errors import NotGeoreferencedWarning
-from rasterio.vrt import WarpedVRT
-from xarray import Dataset, IndexVariable
-from xarray.backends.common import BackendArray
-from xarray.backends.file_manager import CachingFileManager, FileManager
-from xarray.backends.locks import SerializableLock
-from xarray.coding import times, variables
-from xarray.core import indexing
-from xarray.core.dataarray import DataArray
-from xarray.core.dtypes import maybe_promote
-from xarray.core.utils import is_scalar
-from xarray.core.variable import as_variable
-
-from rioxarray.exceptions import RioXarrayError
-from rioxarray.rioxarray import _generate_spatial_coords
+import contextlib
+import importlib.metadata
+import os
+import re
+import threading
+import warnings
+from collections import defaultdict
+from collections.abc import Hashable, Iterable
+from typing import Any, Optional, Union
+
+import numpy
+import rasterio
+from numpy.typing import NDArray
+from packaging import version
+from rasterio.errors import NotGeoreferencedWarning
+from rasterio.vrt import WarpedVRT
+from xarray import Dataset, IndexVariable
+from xarray.backends.common import BackendArray
+from xarray.backends.file_manager import CachingFileManager, FileManager
+from xarray.backends.locks import SerializableLock
+from xarray.coding import times, variables
+from xarray.core import indexing
+from xarray.core.dataarray import DataArray
+from xarray.core.dtypes import maybe_promote
+from xarray.core.utils import is_scalar
+from xarray.core.variable import as_variable
+
+from rioxarray.exceptions import RioXarrayError
+from rioxarray.rioxarray import _generate_spatial_coords
FILL_VALUE_NAMES = ("_FillValue", "missing_value", "fill_value", "nodata")
UNWANTED_RIO_ATTRS = ("nodatavals", "is_tiled", "res")
@@ -122,7 +122,7 @@ Source code for rioxarray._io
NO_LOCK = contextlib.nullcontext()
-def _ensure_warped_vrt(riods, vrt_params):
+def _ensure_warped_vrt(riods, vrt_params):
"""
Ensuire the dataset is represented as a warped vrt
"""
@@ -135,27 +135,27 @@ Source code for rioxarray._io
return riods
-class SingleBandDatasetReader:
+class SingleBandDatasetReader:
"""
Hack to have a DatasetReader behave like it only has one band
"""
- def __init__(self, riods, bidx, vrt_params=None) -> None:
+ def __init__(self, riods, bidx, vrt_params=None) -> None:
self._riods = riods
self._bidx = bidx
self._vrt_params = vrt_params
self._create_vrt(vrt_params=vrt_params)
- def __getattr__(self, __name: str) -> Any:
+ def __getattr__(self, __name: str) -> Any:
return getattr(self._riods, __name)
- def _create_vrt(self, vrt_params):
+ def _create_vrt(self, vrt_params):
if vrt_params is not None and not isinstance(self._riods, WarpedVRT):
self._riods = WarpedVRT(self._riods, **vrt_params)
self._vrt_params = vrt_params
@property
- def name(self):
+ def name(self):
"""
str: name of the dataset. Usually the path.
"""
@@ -164,62 +164,62 @@ Source code for rioxarray._io
return self._riods.name
@property
- def count(self):
+ def count(self):
"""
int: band count
"""
return 1
@property
- def nodata(self):
+ def nodata(self):
"""
Nodata value for the band
"""
return self._riods.nodatavals[self._bidx]
@property
- def offsets(self):
+ def offsets(self):
"""
Offset value for the band
"""
return [self._riods.offsets[self._bidx]]
@property
- def scales(self):
+ def scales(self):
"""
Scale value for the band
"""
return [self._riods.scales[self._bidx]]
@property
- def units(self):
+ def units(self):
"""
Unit for the band
"""
return [self._riods.units[self._bidx]]
@property
- def descriptions(self):
+ def descriptions(self):
"""
Description for the band
"""
return [self._riods.descriptions[self._bidx]]
@property
- def dtypes(self):
+ def dtypes(self):
"""
dtype for the band
"""
return [self._riods.dtypes[self._bidx]]
@property
- def indexes(self):
+ def indexes(self):
"""
indexes for the band
"""
return [self._riods.indexes[self._bidx]]
- def read(self, indexes=None, **kwargs): # pylint: disable=unused-argument
+ def read(self, indexes=None, **kwargs): # pylint: disable=unused-argument
"""
read data for the band
"""
@@ -229,7 +229,7 @@ Source code for rioxarray._io
indexes = [self._bidx + 1]
return self._riods.read(indexes=indexes, **kwargs)
- def tags(self, bidx=None, **kwargs): # pylint: disable=unused-argument
+ def tags(self, bidx=None, **kwargs): # pylint: disable=unused-argument
"""
read tags for the band
"""
@@ -249,7 +249,7 @@ Source code for rioxarray._io
_DASK_GTE_018 = False
-def _get_unsigned_dtype(unsigned, dtype):
+def _get_unsigned_dtype(unsigned, dtype):
"""
Based on: https://github.com/pydata/xarray/blob/abe1e613a96b000ae603c53d135828df532b952e/xarray/coding/variables.py#L306-L334
"""
@@ -261,21 +261,21 @@ Source code for rioxarray._io
return None
-class FileHandleLocal(threading.local):
+class FileHandleLocal(threading.local):
"""
This contains the thread local ThreadURIManager
"""
- def __init__(self): # pylint: disable=super-init-not-called
+ def __init__(self): # pylint: disable=super-init-not-called
self.thread_manager = None # Initialises in each thread
-class ThreadURIManager:
+class ThreadURIManager:
"""
This handles opening & closing file handles in each thread.
"""
- def __init__(
+ def __init__(
self,
opener,
*args,
@@ -289,7 +289,7 @@ Source code for rioxarray._io
self._file_handle = None
@property
- def file_handle(self):
+ def file_handle(self):
"""
File handle returned by the opener.
"""
@@ -298,7 +298,7 @@ Source code for rioxarray._io
self._file_handle = self._opener(*self._args, mode=self._mode, **self._kwargs)
return self._file_handle
- def close(self):
+ def close(self):
"""
Close file handle.
"""
@@ -306,22 +306,22 @@ Source code for rioxarray._io
self._file_handle.close()
self._file_handle = None
- def __del__(self):
+ def __del__(self):
self.close()
- def __enter__(self):
+ def __enter__(self):
return self
- def __exit__(self, type_, value, traceback):
+ def __exit__(self, type_, value, traceback):
self.close()
-class URIManager(FileManager):
+class URIManager(FileManager):
"""
The URI manager is used for lockless reading
"""
- def __init__(
+ def __init__(
self,
opener,
*args,
@@ -334,7 +334,7 @@ Source code for rioxarray._io
self._kwargs = {} if kwargs is None else dict(kwargs)
self._local = FileHandleLocal()
- def acquire(self, needs_lock=True):
+ def acquire(self, needs_lock=True):
if self._local.thread_manager is None:
self._local.thread_manager = ThreadURIManager(
self._opener, *self._args, mode=self._mode, kwargs=self._kwargs
@@ -342,37 +342,37 @@ Source code for rioxarray._io
return self._local.thread_manager.file_handle
@contextlib.contextmanager
- def acquire_context(self, needs_lock=True):
+ def acquire_context(self, needs_lock=True):
try:
yield self.acquire(needs_lock=needs_lock)
except Exception:
self.close(needs_lock=needs_lock)
raise
- def close(self, needs_lock=True):
+ def close(self, needs_lock=True):
if self._local.thread_manager is not None:
self._local.thread_manager.close()
self._local.thread_manager = None
- def __del__(self):
+ def __del__(self):
self.close(needs_lock=False)
- def __getstate__(self):
+ def __getstate__(self):
"""State for pickling."""
return (self._opener, self._args, self._mode, self._kwargs)
- def __setstate__(self, state):
+ def __setstate__(self, state):
"""Restore from a pickle."""
opener, args, mode, kwargs = state
self.__init__(opener, *args, mode=mode, kwargs=kwargs)
-class RasterioArrayWrapper(BackendArray):
+class RasterioArrayWrapper(BackendArray):
"""A wrapper around rasterio dataset objects"""
# pylint: disable=too-many-instance-attributes
- def __init__(
+ def __init__(
self,
*,
manager,
@@ -420,27 +420,27 @@ Source code for rioxarray._io
self._dtype = dtype
@property
- def dtype(self):
+ def dtype(self):
"""
Data type of the array
"""
return self._dtype
@property
- def fill_value(self):
+ def fill_value(self):
"""
Fill value of the array
"""
return self._fill_value
@property
- def shape(self):
+ def shape(self):
"""
Shape of the array
"""
return self._shape
- def _get_indexer(self, key):
+ def _get_indexer(self, key):
"""Get indexer for rasterio array.
Parameter
@@ -498,7 +498,7 @@ Source code for rioxarray._io
return band_key, tuple(window), tuple(squeeze_axis), tuple(np_inds)
- def _getitem(self, key):
+ def _getitem(self, key):
band_key, window, squeeze_axis, np_inds = self._get_indexer(key)
if not band_key or any(start == stop for (start, stop) in window):
# no need to do IO
@@ -531,13 +531,13 @@ Source code for rioxarray._io
out = numpy.squeeze(out, axis=squeeze_axis)
return out[np_inds]
- def __getitem__(self, key):
+ def __getitem__(self, key):
return indexing.explicit_indexing_adapter(
key, self.shape, indexing.IndexingSupport.OUTER, self._getitem
)
-def _parse_envi(meta):
+def _parse_envi(meta):
"""Parse ENVI metadata into Python data structures.
See the link for information on the ENVI header file format:
@@ -556,10 +556,10 @@ Source code for rioxarray._io
"""
- def parsevec(value):
+ def parsevec(value):
return numpy.fromstring(value.strip("{}"), dtype="float", sep=",")
- def default(value):
+ def default(value):
return value.strip("{}")
parse = {"wavelength": parsevec, "fwhm": parsevec}
@@ -567,7 +567,7 @@ Source code for rioxarray._io
return parsed_meta
-def _rasterio_to_numpy_dtype(dtypes):
+def _rasterio_to_numpy_dtype(dtypes):
"""Numpy dtype from first entry of rasterio dataset.dtypes"""
# rasterio has some special dtype names (complex_int16 -> numpy.complex64)
if dtypes[0] == "complex_int16":
@@ -578,7 +578,7 @@ Source code for rioxarray._io
return dtype
-def _to_numeric(value: Any) -> float:
+def _to_numeric(value: Any) -> float:
"""
Convert the value to a number
"""
@@ -592,7 +592,7 @@ Source code for rioxarray._io
return value
-def _parse_tag(*, key: str, value: Any) -> tuple[str, Any]:
+def _parse_tag(*, key: str, value: Any) -> tuple[str, Any]:
# NC_GLOBAL is appended to tags with netcdf driver and is not really needed
key = key.split("NC_GLOBAL#")[-1]
if value.startswith("{") and value.endswith("}"):
@@ -607,7 +607,7 @@ Source code for rioxarray._io
return key, value
-def _parse_tags(tags: dict) -> dict:
+def _parse_tags(tags: dict) -> dict:
parsed_tags = {}
for key, value in tags.items():
key, value = _parse_tag(key=key, value=value)
@@ -632,7 +632,7 @@ Source code for rioxarray._io
}
-def _load_netcdf_attrs(*, tags: dict, data_array: DataArray) -> None:
+def _load_netcdf_attrs(*, tags: dict, data_array: DataArray) -> None:
"""
Loads the netCDF attributes into the data array
@@ -649,7 +649,7 @@ Source code for rioxarray._io
data_array.coords[variable_name].attrs.update({attr_name: value})
-def _parse_netcdf_attr_array(attr: Union[NDArray, str], *, dtype=None) -> NDArray:
+def _parse_netcdf_attr_array(attr: Union[NDArray, str], *, dtype=None) -> NDArray:
"""
Expected format: '{2,6}' or '[2. 6.]'
"""
@@ -666,7 +666,7 @@ Source code for rioxarray._io
return numpy.array(value, dtype=dtype)
-def _load_netcdf_1d_coords(tags: dict) -> dict:
+def _load_netcdf_1d_coords(tags: dict) -> dict:
"""
Dimension information:
- NETCDF_DIM_EXTRA: '{time}' (comma separated list of dim names)
@@ -690,7 +690,7 @@ Source code for rioxarray._io
return coords
-def build_subdataset_filter(
+def build_subdataset_filter(
group_names: Optional[Union[str, list[str], tuple[str, ...]]],
variable_names: Optional[Union[str, list[str], tuple[str, ...]]],
):
@@ -731,7 +731,7 @@ Source code for rioxarray._io
)
-def _get_rasterio_attrs(riods: RasterioReader):
+def _get_rasterio_attrs(riods: RasterioReader):
"""
Get rasterio specific attributes
"""
@@ -779,7 +779,7 @@ Source code for rioxarray._io
return attrs
-def _decode_datetime_cf(
+def _decode_datetime_cf(
data_array: DataArray,
decode_times: bool,
decode_timedelta: Optional[bool],
@@ -820,7 +820,7 @@ Source code for rioxarray._io
return data_array
-def _parse_driver_tags(
+def _parse_driver_tags(
riods: RasterioReader,
attrs: dict,
coords: dict,
@@ -841,7 +841,7 @@ Source code for rioxarray._io
attrs[key] = value
-def _pop_global_netcdf_attrs_from_vars(dataset_to_clean: Dataset) -> Dataset:
+def _pop_global_netcdf_attrs_from_vars(dataset_to_clean: Dataset) -> Dataset:
# remove GLOBAL netCDF attributes from dataset variables
for coord in dataset_to_clean.coords:
for variable in dataset_to_clean.variables:
@@ -854,7 +854,7 @@ Source code for rioxarray._io
return dataset_to_clean
-def _subdataset_groups_to_dataset(
+def _subdataset_groups_to_dataset(
*, dim_groups: dict[Hashable, dict[Hashable, DataArray]], global_tags: dict
) -> Union[Dataset, list[Dataset]]:
if dim_groups:
@@ -864,7 +864,7 @@ Source code for rioxarray._io
Dataset(dim_group, attrs=global_tags)
)
- def _ds_close():
+ def _ds_close():
# pylint: disable=cell-var-from-loop
for data_var in dim_group.values():
data_var.close()
@@ -878,7 +878,7 @@ Source code for rioxarray._io
return dataset
-def _load_subdatasets(
+def _load_subdatasets(
riods: RasterioReader,
*,
group: Optional[Union[str, list[str], tuple[str, ...]]],
@@ -924,7 +924,7 @@ Source code for rioxarray._io
)
-def _load_bands_as_variables(
+def _load_bands_as_variables(
riods: RasterioReader,
*,
parse_coordinates: bool,
@@ -969,7 +969,7 @@ Source code for rioxarray._io
)
dataset = Dataset(data_vars, attrs=global_tags)
- def _ds_close():
+ def _ds_close():
for data_var in data_vars.values():
data_var.close()
@@ -977,7 +977,7 @@ Source code for rioxarray._io
return dataset
-def _prepare_dask(
+def _prepare_dask(
*,
result: DataArray,
riods: RasterioReader,
@@ -989,7 +989,7 @@ Source code for rioxarray._io
Prepare the data for dask computations
"""
# pylint: disable=import-outside-toplevel
- from dask.base import tokenize
+ from dask.base import tokenize
# augment the token with the file modification time
try:
@@ -999,7 +999,7 @@ Source code for rioxarray._io
mtime = None
if chunks in (True, "auto"):
- from dask.array.core import normalize_chunks
+ from dask.array.core import normalize_chunks
if not _DASK_GTE_018:
raise NotImplementedError("Automatic chunking requires dask >= 0.18.0")
@@ -1018,7 +1018,7 @@ Source code for rioxarray._io
return result.chunk(chunks, name_prefix=name_prefix, token=token)
-def _handle_encoding(
+def _handle_encoding(
*,
result: DataArray,
mask_and_scale: bool,
@@ -1061,7 +1061,7 @@ Source code for rioxarray._io
)
-def _single_band_open(*args, bidx=0, **kwargs):
+def _single_band_open(*args, bidx=0, **kwargs):
"""
Open file as if it only has a single band
"""
@@ -1073,7 +1073,7 @@ Source code for rioxarray._io
[docs]
-def open_rasterio(
+def open_rasterio(
filename: Union[
str,
os.PathLike,
diff --git a/latest/_modules/rioxarray/_options.html b/latest/_modules/rioxarray/_options.html
index 2774c20a..637964e8 100644
--- a/latest/_modules/rioxarray/_options.html
+++ b/latest/_modules/rioxarray/_options.html
@@ -6,7 +6,7 @@
rioxarray._options — rioxarray 0.18.2.dev0 documentation
-
+
@@ -85,7 +85,7 @@ Source code for rioxarray._options
This file was adopted from: https://github.com/pydata/xarray # noqa
Source file: https://github.com/pydata/xarray/blob/2ab0666c1fcc493b1e0ebc7db14500c427f8804e/xarray/core/options.py # noqa
"""
-from typing import Any
+from typing import Any
EXPORT_GRID_MAPPING = "export_grid_mapping"
SKIP_MISSING_SPATIAL_DIMS = "skip_missing_spatial_dims"
@@ -101,7 +101,7 @@ Source code for rioxarray._options
}
-def get_option(key: str) -> Any:
+def get_option(key: str) -> Any:
"""
Get the global rioxarray option.
@@ -121,7 +121,7 @@ Source code for rioxarray._options
[docs]
-class set_options: # pylint: disable=invalid-name
+class set_options: # pylint: disable=invalid-name
"""
Set the global rioxarray option.
@@ -154,7 +154,7 @@ Source code for rioxarray._options
"""
- def __init__(self, **kwargs):
+ def __init__(self, **kwargs):
self.old = OPTIONS.copy()
for key, value in kwargs.items():
if key not in OPTIONS:
@@ -166,10 +166,10 @@ Source code for rioxarray._options
raise ValueError(f"option {key!r} gave an invalid value: {value!r}.")
OPTIONS[key] = value
- def __enter__(self):
+ def __enter__(self):
return
- def __exit__(self, exc_type, exc_value, traceback):
+ def __exit__(self, exc_type, exc_value, traceback):
global OPTIONS # pylint: disable=global-statement
OPTIONS = self.old
diff --git a/latest/_modules/rioxarray/_show_versions.html b/latest/_modules/rioxarray/_show_versions.html
index e92ac223..181e60e9 100644
--- a/latest/_modules/rioxarray/_show_versions.html
+++ b/latest/_modules/rioxarray/_show_versions.html
@@ -6,7 +6,7 @@
rioxarray._show_versions — rioxarray 0.18.2.dev0 documentation
-
+
@@ -84,13 +84,13 @@ Source code for rioxarray._show_versions
which was adapted from :func:`pandas.show_versions`
"""
# pylint: disable=import-outside-toplevel
-import importlib.metadata
-import os
-import platform
-import sys
+import importlib.metadata
+import os
+import platform
+import sys
-def _get_sys_info() -> dict[str, str]:
+def _get_sys_info() -> dict[str, str]:
"""System information
Return
------
@@ -106,7 +106,7 @@ Source code for rioxarray._show_versions
return dict(blob)
-def _get_main_info() -> dict[str, str]:
+def _get_main_info() -> dict[str, str]:
"""Get the main dependency information to hightlight.
Returns
@@ -114,7 +114,7 @@ Source code for rioxarray._show_versions
proj_info: dict
system GDAL information
"""
- import rasterio
+ import rasterio
try:
proj_data = os.pathsep.join(rasterio._env.get_proj_data_search_paths())
@@ -138,7 +138,7 @@ Source code for rioxarray._show_versions
return dict(blob)
-def _get_deps_info() -> dict[str, str]:
+def _get_deps_info() -> dict[str, str]:
"""Overview of the installed version of dependencies
Returns
-------
@@ -147,7 +147,7 @@ Source code for rioxarray._show_versions
"""
deps = ["scipy", "pyproj"]
- def get_version(module):
+ def get_version(module):
try:
return importlib.metadata.version(module)
except importlib.metadata.PackageNotFoundError:
@@ -156,7 +156,7 @@ Source code for rioxarray._show_versions
return {dep: get_version(dep) for dep in deps}
-def _print_info_dict(info_dict: dict[str, str]) -> None:
+def _print_info_dict(info_dict: dict[str, str]) -> None:
"""Print the information dictionary"""
for key, stat in info_dict.items():
print(f"{key:>10}: {stat}")
@@ -164,7 +164,7 @@ Source code for rioxarray._show_versions
[docs]
-def show_versions() -> None:
+def show_versions() -> None:
"""
.. versionadded:: 0.0.26
diff --git a/latest/_modules/rioxarray/exceptions.html b/latest/_modules/rioxarray/exceptions.html
index 8f17c524..95394665 100644
--- a/latest/_modules/rioxarray/exceptions.html
+++ b/latest/_modules/rioxarray/exceptions.html
@@ -6,7 +6,7 @@
rioxarray.exceptions — rioxarray 0.18.2.dev0 documentation
-
+
@@ -84,70 +84,70 @@ Source code for rioxarray.exceptions
[docs]
-class RioXarrayError(RuntimeError):
+class RioXarrayError(RuntimeError):
"""This is the base exception for errors in the rioxarray extension."""
[docs]
-class NoDataInBounds(RioXarrayError):
+class NoDataInBounds(RioXarrayError):
"""This is for when there are no data in the bounds for clipping a raster."""
[docs]
-class SingleVariableDataset(RioXarrayError):
+class SingleVariableDataset(RioXarrayError):
"""This is for when you have a dataset with a single variable."""
[docs]
-class DimensionError(RioXarrayError):
+class DimensionError(RioXarrayError):
"""This is raised when there are more dimensions than is supported by the method"""
[docs]
-class MissingSpatialDimensionError(DimensionError):
+class MissingSpatialDimensionError(DimensionError):
"""This is raised when the dimension cannot be found"""
[docs]
-class TooManyDimensions(DimensionError):
+class TooManyDimensions(DimensionError):
"""This is raised when there are more dimensions than is supported by the method"""
[docs]
-class InvalidDimensionOrder(DimensionError):
+class InvalidDimensionOrder(DimensionError):
"""This is raised when there the dimensions are not ordered correctly."""
[docs]
-class OneDimensionalRaster(DimensionError):
+class OneDimensionalRaster(DimensionError):
"""This is an error when you have a 1 dimensional raster."""
[docs]
-class DimensionMissingCoordinateError(RioXarrayError):
+class DimensionMissingCoordinateError(RioXarrayError):
"""This is raised when the dimension does not have the supporting coordinate."""
[docs]
-class MissingCRS(RioXarrayError):
+class MissingCRS(RioXarrayError):
"""Missing the CRS in the dataset."""
diff --git a/latest/_modules/rioxarray/merge.html b/latest/_modules/rioxarray/merge.html
index 719377e0..6487908a 100644
--- a/latest/_modules/rioxarray/merge.html
+++ b/latest/_modules/rioxarray/merge.html
@@ -6,7 +6,7 @@
rioxarray.merge — rioxarray 0.18.2.dev0 documentation
-
+
@@ -81,20 +81,20 @@ Source code for rioxarray.merge
This module allows you to merge xarray Datasets/DataArrays
geospatially with the `rasterio.merge` module.
"""
-from collections.abc import Sequence
-from typing import Callable, Optional, Union
+from collections.abc import Sequence
+from typing import Callable, Optional, Union
-import numpy
-from rasterio.crs import CRS
-from rasterio.io import MemoryFile
-from rasterio.merge import merge as _rio_merge
-from xarray import DataArray, Dataset
+import numpy
+from rasterio.crs import CRS
+from rasterio.io import MemoryFile
+from rasterio.merge import merge as _rio_merge
+from xarray import DataArray, Dataset
-from rioxarray._io import open_rasterio
-from rioxarray.rioxarray import _get_nonspatial_coords
+from rioxarray._io import open_rasterio
+from rioxarray.rioxarray import _get_nonspatial_coords
-class RasterioDatasetDuck:
+class RasterioDatasetDuck:
"""
This class is to provide the attributes and methods necessary
to make the :func:`rasterio.merge.merge` function think that
@@ -103,7 +103,7 @@ Source code for rioxarray.merge
# pylint: disable=too-many-instance-attributes
- def __init__(self, xds: DataArray):
+ def __init__(self, xds: DataArray):
self._xds = xds
self.crs = xds.rio.crs
self.bounds = xds.rio.bounds(recalc=True)
@@ -134,7 +134,7 @@ Source code for rioxarray.merge
or self._xds.encoding.get("_Unsigned") is not None
)
- def colormap(self, *args, **kwargs) -> None:
+ def colormap(self, *args, **kwargs) -> None:
"""
colormap is only used for writing to a file.
This never happens with rioxarray merge.
@@ -142,7 +142,7 @@ Source code for rioxarray.merge
# pylint: disable=unused-argument
return None
- def read(self, *args, **kwargs) -> numpy.ma.MaskedArray:
+ def read(self, *args, **kwargs) -> numpy.ma.MaskedArray:
"""
This method is meant to be used by the rasterio.merge.merge function.
"""
@@ -161,7 +161,7 @@ Source code for rioxarray.merge
[docs]
-def merge_arrays(
+def merge_arrays(
dataarrays: Sequence[DataArray],
*,
bounds: Optional[tuple] = None,
@@ -282,7 +282,7 @@ Source code for rioxarray.merge
[docs]
-def merge_datasets(
+def merge_datasets(
datasets: Sequence[Dataset],
*,
bounds: Optional[tuple] = None,
diff --git a/latest/_modules/rioxarray/raster_array.html b/latest/_modules/rioxarray/raster_array.html
index ff89c236..ddee3053 100644
--- a/latest/_modules/rioxarray/raster_array.html
+++ b/latest/_modules/rioxarray/raster_array.html
@@ -6,7 +6,7 @@
rioxarray.raster_array — rioxarray 0.18.2.dev0 documentation
-
+
@@ -89,34 +89,34 @@ Source code for rioxarray.raster_array
"""
-import copy
-import os
-from collections.abc import Hashable, Iterable, Mapping
-from pathlib import Path
-from typing import Any, Literal, Optional, Union
-
-import numpy
-import rasterio
-import rasterio.mask
-import rasterio.warp
-import xarray
-from affine import Affine
-from rasterio.dtypes import dtype_rev
-from rasterio.enums import Resampling
-from rasterio.features import geometry_mask
-from xarray.backends.file_manager import FileManager
-from xarray.core.dtypes import get_fill_value
-
-from rioxarray._io import FILL_VALUE_NAMES, UNWANTED_RIO_ATTRS
-from rioxarray.crs import crs_from_user_input
-from rioxarray.exceptions import (
+import copy
+import os
+from collections.abc import Hashable, Iterable, Mapping
+from pathlib import Path
+from typing import Any, Literal, Optional, Union
+
+import numpy
+import rasterio
+import rasterio.mask
+import rasterio.warp
+import xarray
+from affine import Affine
+from rasterio.dtypes import dtype_rev
+from rasterio.enums import Resampling
+from rasterio.features import geometry_mask
+from xarray.backends.file_manager import FileManager
+from xarray.core.dtypes import get_fill_value
+
+from rioxarray._io import FILL_VALUE_NAMES, UNWANTED_RIO_ATTRS
+from rioxarray.crs import crs_from_user_input
+from rioxarray.exceptions import (
MissingCRS,
NoDataInBounds,
OneDimensionalRaster,
RioXarrayError,
)
-from rioxarray.raster_writer import RasterioWriter, _ensure_nodata_dtype
-from rioxarray.rioxarray import (
+from rioxarray.raster_writer import RasterioWriter, _ensure_nodata_dtype
+from rioxarray.rioxarray import (
XRasterBase,
_get_data_var_message,
_make_coords,
@@ -147,7 +147,7 @@ Source code for rioxarray.raster_array
}
-def _generate_attrs(
+def _generate_attrs(
*, src_data_array: xarray.DataArray, dst_nodata: Optional[float]
) -> dict[str, Any]:
# add original attributes
@@ -168,7 +168,7 @@ Source code for rioxarray.raster_array
return new_attrs
-def _add_attrs_proj(
+def _add_attrs_proj(
*, new_data_array: xarray.DataArray, src_data_array: xarray.DataArray
) -> xarray.DataArray:
"""Make sure attributes and projection correct"""
@@ -198,7 +198,7 @@ Source code for rioxarray.raster_array
return new_data_array
-def _make_dst_affine(
+def _make_dst_affine(
*,
src_data_array: xarray.DataArray,
src_crs: rasterio.crs.CRS,
@@ -241,7 +241,7 @@ Source code for rioxarray.raster_array
return dst_affine, dst_width, dst_height
-def _clip_from_disk(
+def _clip_from_disk(
xds: xarray.DataArray,
*,
geometries: Iterable,
@@ -285,7 +285,7 @@ Source code for rioxarray.raster_array
return None
-def _clip_xarray(
+def _clip_xarray(
xds: xarray.DataArray,
*,
geometries: Iterable,
@@ -326,10 +326,10 @@ Source code for rioxarray.raster_array
[docs]
@xarray.register_dataarray_accessor("rio")
-class RasterArray(XRasterBase):
+class RasterArray(XRasterBase):
"""This is the GIS extension for :obj:`xarray.DataArray`"""
- def __init__(self, xarray_obj: xarray.DataArray):
+ def __init__(self, xarray_obj: xarray.DataArray):
super().__init__(xarray_obj)
self._obj: xarray.DataArray
# properties
@@ -340,7 +340,7 @@ Source code for rioxarray.raster_array
[docs]
- def set_nodata(
+ def set_nodata(
self, input_nodata: Optional[float], *, inplace: bool = True
) -> xarray.DataArray:
"""
@@ -366,7 +366,7 @@ Source code for rioxarray.raster_array
[docs]
- def write_nodata(
+ def write_nodata(
self, input_nodata: Optional[float], *, encoded: bool = False, inplace=False
) -> xarray.DataArray:
"""
@@ -430,7 +430,7 @@ Source code for rioxarray.raster_array
@property
- def encoded_nodata(self) -> Optional[float]:
+ def encoded_nodata(self) -> Optional[float]:
"""Return the encoded nodata value for the dataset if encoded."""
encoded_nodata = self._obj.encoding.get("_FillValue")
if encoded_nodata is None:
@@ -440,7 +440,7 @@ Source code for rioxarray.raster_array
)
@property
- def nodata(self) -> Optional[float]:
+ def nodata(self) -> Optional[float]:
"""Get the nodata value for the dataset."""
if self._nodata is not None:
return None if self._nodata is False else self._nodata
@@ -477,7 +477,7 @@ Source code for rioxarray.raster_array
[docs]
- def reproject(
+ def reproject(
self,
dst_crs: Any,
*,
@@ -617,7 +617,7 @@ Source code for rioxarray.raster_array
return xda
- def _get_dst_nodata(self, nodata: Optional[float]) -> Optional[float]:
+ def _get_dst_nodata(self, nodata: Optional[float]) -> Optional[float]:
default_nodata = (
_NODATA_DTYPE_MAP.get(dtype_rev[self._obj.dtype.name])
if self.nodata is None
@@ -626,7 +626,7 @@ Source code for rioxarray.raster_array
dst_nodata = default_nodata if nodata is None else nodata
return dst_nodata
- def _create_dst_data(self, *, dst_height: int, dst_width: int) -> numpy.ndarray:
+ def _create_dst_data(self, *, dst_height: int, dst_width: int) -> numpy.ndarray:
extra_dim = self._check_dimensions()
if extra_dim:
dst_data = numpy.zeros(
@@ -639,7 +639,7 @@ Source code for rioxarray.raster_array
[docs]
- def reproject_match(
+ def reproject_match(
self,
match_data_array: Union[xarray.DataArray, xarray.Dataset],
*,
@@ -705,7 +705,7 @@ Source code for rioxarray.raster_array
[docs]
- def pad_xy(
+ def pad_xy(
self,
minx: float,
miny: float,
@@ -788,7 +788,7 @@ Source code for rioxarray.raster_array
[docs]
- def pad_box(
+ def pad_box(
self,
minx: float,
miny: float,
@@ -846,7 +846,7 @@ Source code for rioxarray.raster_array
[docs]
- def clip_box(
+ def clip_box(
self,
minx: float,
miny: float,
@@ -984,7 +984,7 @@ Source code for rioxarray.raster_array
[docs]
- def clip(
+ def clip(
self,
geometries: Iterable,
crs: Optional[Any] = None,
@@ -1085,7 +1085,7 @@ Source code for rioxarray.raster_array
return cropped_ds
- def _interpolate_na(
+ def _interpolate_na(
self,
src_data: Any,
*,
@@ -1107,13 +1107,13 @@ Source code for rioxarray.raster_array
An interpolated :class:`numpy.ndarray`.
"""
try:
- from scipy.interpolate import ( # pylint: disable=import-outside-toplevel,import-error
+ from scipy.interpolate import ( # pylint: disable=import-outside-toplevel,import-error
griddata,
)
except ModuleNotFoundError as err:
raise ModuleNotFoundError(
"scipy is not found. Use rioxarray[interp] to install."
- ) from err
+ ) from err
src_data_flat = src_data.flatten()
try:
@@ -1142,7 +1142,7 @@ Source code for rioxarray.raster_array
[docs]
- def interpolate_na(
+ def interpolate_na(
self, method: Literal["linear", "nearest", "cubic"] = "nearest"
) -> xarray.DataArray:
"""
@@ -1195,7 +1195,7 @@ Source code for rioxarray.raster_array
[docs]
- def to_raster(
+ def to_raster(
self,
raster_path: Union[str, os.PathLike],
*,
diff --git a/latest/_modules/rioxarray/raster_dataset.html b/latest/_modules/rioxarray/raster_dataset.html
index ae6e9ed0..339a4c30 100644
--- a/latest/_modules/rioxarray/raster_dataset.html
+++ b/latest/_modules/rioxarray/raster_dataset.html
@@ -6,7 +6,7 @@
rioxarray.raster_dataset — rioxarray 0.18.2.dev0 documentation
-
+
@@ -81,35 +81,35 @@ Source code for rioxarray.raster_dataset
This module is an extension for xarray to provide rasterio capabilities
to xarray datasets.
"""
-import os
-from collections.abc import Iterable, Mapping
-from typing import Any, Literal, Optional, Union
-from uuid import uuid4
+import os
+from collections.abc import Iterable, Mapping
+from typing import Any, Literal, Optional, Union
+from uuid import uuid4
-import numpy
-import rasterio.crs
-import xarray
-from affine import Affine
-from rasterio.enums import Resampling
+import numpy
+import rasterio.crs
+import xarray
+from affine import Affine
+from rasterio.enums import Resampling
-from rioxarray._options import SKIP_MISSING_SPATIAL_DIMS, get_option
-from rioxarray.exceptions import MissingSpatialDimensionError, RioXarrayError
-from rioxarray.rioxarray import XRasterBase, _get_spatial_dims
+from rioxarray._options import SKIP_MISSING_SPATIAL_DIMS, get_option
+from rioxarray.exceptions import MissingSpatialDimensionError, RioXarrayError
+from rioxarray.rioxarray import XRasterBase, _get_spatial_dims
[docs]
@xarray.register_dataset_accessor("rio")
-class RasterDataset(XRasterBase):
+class RasterDataset(XRasterBase):
"""This is the GIS extension for :class:`xarray.Dataset`"""
@property
- def vars(self) -> list:
+ def vars(self) -> list:
"""list: Returns non-coordinate varibles"""
return list(self._obj.data_vars)
@property
- def crs(self) -> Optional[rasterio.crs.CRS]:
+ def crs(self) -> Optional[rasterio.crs.CRS]:
""":obj:`rasterio.crs.CRS`:
Retrieve projection from `xarray.Dataset`
"""
@@ -138,7 +138,7 @@ Source code for rioxarray.raster_dataset
[docs]
- def reproject(
+ def reproject(
self,
dst_crs: Any,
*,
@@ -225,7 +225,7 @@ Source code for rioxarray.raster_dataset
[docs]
- def reproject_match(
+ def reproject_match(
self,
match_data_array: Union[xarray.DataArray, xarray.Dataset],
*,
@@ -281,7 +281,7 @@ Source code for rioxarray.raster_dataset
[docs]
- def pad_box(
+ def pad_box(
self,
minx: float,
miny: float,
@@ -342,7 +342,7 @@ Source code for rioxarray.raster_dataset
[docs]
- def clip_box(
+ def clip_box(
self,
minx: float,
miny: float,
@@ -418,7 +418,7 @@ Source code for rioxarray.raster_dataset
[docs]
- def clip(
+ def clip(
self,
geometries: Iterable,
crs: Optional[Any] = None,
@@ -509,7 +509,7 @@ Source code for rioxarray.raster_dataset
[docs]
- def interpolate_na(
+ def interpolate_na(
self, method: Literal["linear", "nearest", "cubic"] = "nearest"
) -> xarray.Dataset:
"""
@@ -551,7 +551,7 @@ Source code for rioxarray.raster_dataset
[docs]
- def to_raster(
+ def to_raster(
self,
raster_path: Union[str, os.PathLike],
*,
diff --git a/latest/_modules/rioxarray/rioxarray.html b/latest/_modules/rioxarray/rioxarray.html
index 1ed34e2b..338136a4 100644
--- a/latest/_modules/rioxarray/rioxarray.html
+++ b/latest/_modules/rioxarray/rioxarray.html
@@ -6,7 +6,7 @@
rioxarray.rioxarray — rioxarray 0.18.2.dev0 documentation
-
+
@@ -83,26 +83,26 @@ Source code for rioxarray.rioxarray
"""
# pylint: disable=too-many-lines
-import json
-import math
-import warnings
-from collections.abc import Hashable, Iterable
-from typing import Any, Literal, Optional, Union
-
-import numpy
-import pyproj
-import rasterio.warp
-import rasterio.windows
-import xarray
-from affine import Affine
-from pyproj.aoi import AreaOfInterest
-from pyproj.database import query_utm_crs_info
-from rasterio.control import GroundControlPoint
-from rasterio.crs import CRS
-
-from rioxarray._options import EXPORT_GRID_MAPPING, get_option
-from rioxarray.crs import crs_from_user_input
-from rioxarray.exceptions import (
+import json
+import math
+import warnings
+from collections.abc import Hashable, Iterable
+from typing import Any, Literal, Optional, Union
+
+import numpy
+import pyproj
+import rasterio.warp
+import rasterio.windows
+import xarray
+from affine import Affine
+from pyproj.aoi import AreaOfInterest
+from pyproj.database import query_utm_crs_info
+from rasterio.control import GroundControlPoint
+from rasterio.crs import CRS
+
+from rioxarray._options import EXPORT_GRID_MAPPING, get_option
+from rioxarray.crs import crs_from_user_input
+from rioxarray.exceptions import (
DimensionError,
DimensionMissingCoordinateError,
InvalidDimensionOrder,
@@ -117,7 +117,7 @@ Source code for rioxarray.rioxarray
DEFAULT_GRID_MAP = "spatial_ref"
-def _affine_has_rotation(affine: Affine) -> bool:
+def _affine_has_rotation(affine: Affine) -> bool:
"""
Determine if the affine has rotation.
@@ -133,7 +133,7 @@ Source code for rioxarray.rioxarray
return affine.b == affine.d != 0
-def _resolution(affine: Affine) -> tuple[float, float]:
+def _resolution(affine: Affine) -> tuple[float, float]:
"""
Determine if the resolution of the affine.
If it has rotation, the sign of the resolution is lost.
@@ -161,7 +161,7 @@ Source code for rioxarray.rioxarray
)
-def affine_to_coords(
+def affine_to_coords(
affine: Affine, width: int, height: int, *, x_dim: str = "x", y_dim: str = "y"
) -> dict[str, numpy.ndarray]:
"""Generate 1d pixel centered coordinates from affine.
@@ -198,7 +198,7 @@ Source code for rioxarray.rioxarray
return {y_dim: y_coords, x_dim: x_coords}
-def _generate_spatial_coords(
+def _generate_spatial_coords(
*, affine: Affine, width: int, height: int
) -> dict[Hashable, Any]:
"""get spatial coords in new transform"""
@@ -214,7 +214,7 @@ Source code for rioxarray.rioxarray
}
-def _get_nonspatial_coords(
+def _get_nonspatial_coords(
src_data_array: Union[xarray.DataArray, xarray.Dataset]
) -> dict[Hashable, Union[xarray.Variable, xarray.IndexVariable]]:
coords: dict[Hashable, Union[xarray.Variable, xarray.IndexVariable]] = {}
@@ -222,9 +222,13 @@ Source code for rioxarray.rioxarray
src_data_array.rio.x_dim,
src_data_array.rio.y_dim,
DEFAULT_GRID_MAP,
- "xc",
- "yc",
}:
+ # skip 2D spatial coords
+ if (
+ src_data_array.rio.x_dim in src_data_array[coord].dims
+ and src_data_array.rio.y_dim in src_data_array[coord].dims
+ ):
+ continue
if src_data_array[coord].ndim == 1:
coords[coord] = xarray.IndexVariable(
src_data_array[coord].dims,
@@ -240,7 +244,7 @@ Source code for rioxarray.rioxarray
return coords
-def _make_coords(
+def _make_coords(
*,
src_data_array: Union[xarray.DataArray, xarray.Dataset],
dst_affine: Affine,
@@ -266,7 +270,7 @@ Source code for rioxarray.rioxarray
return coords
-def _get_data_var_message(obj: Union[xarray.DataArray, xarray.Dataset]) -> str:
+def _get_data_var_message(obj: Union[xarray.DataArray, xarray.Dataset]) -> str:
"""
Get message for named data variables.
"""
@@ -276,7 +280,7 @@ Source code for rioxarray.rioxarray
return ""
-def _get_spatial_dims(
+def _get_spatial_dims(
obj: Union[xarray.Dataset, xarray.DataArray], *, var: Union[Any, Hashable]
) -> tuple[str, str]:
"""
@@ -291,10 +295,10 @@ Source code for rioxarray.rioxarray
)
return obj.rio.x_dim, obj.rio.y_dim
except MissingSpatialDimensionError:
- raise err from None
+ raise err from None
-def _has_spatial_dims(
+def _has_spatial_dims(
obj: Union[xarray.Dataset, xarray.DataArray], *, var: Union[Any, Hashable]
) -> bool:
"""
@@ -308,7 +312,7 @@ Source code for rioxarray.rioxarray
return True
-def _order_bounds(
+def _order_bounds(
*,
minx: float,
miny: float,
@@ -338,11 +342,11 @@ Source code for rioxarray.rioxarray
[docs]
-class XRasterBase:
+class XRasterBase:
"""This is the base class for the GIS extensions for xarray"""
# pylint: disable=too-many-instance-attributes
- def __init__(self, xarray_obj: Union[xarray.DataArray, xarray.Dataset]):
+ def __init__(self, xarray_obj: Union[xarray.DataArray, xarray.Dataset]):
self._obj: Union[xarray.DataArray, xarray.Dataset] = xarray_obj
self._x_dim: Optional[Hashable] = None
@@ -380,7 +384,7 @@ Source code for rioxarray.rioxarray
self._gcps: Optional[list[GroundControlPoint]] = None
@property
- def crs(self) -> Optional[rasterio.crs.CRS]:
+ def crs(self) -> Optional[rasterio.crs.CRS]:
""":obj:`rasterio.crs.CRS`:
Retrieve projection from :obj:`xarray.Dataset` | :obj:`xarray.DataArray`
"""
@@ -414,7 +418,7 @@ Source code for rioxarray.rioxarray
return None
return self._crs
- def _get_obj(self, inplace: bool) -> Union[xarray.Dataset, xarray.DataArray]:
+ def _get_obj(self, inplace: bool) -> Union[xarray.Dataset, xarray.DataArray]:
"""
Get the object to modify.
@@ -441,7 +445,7 @@ Source code for rioxarray.rioxarray
[docs]
- def set_crs(
+ def set_crs(
self, input_crs: Any, inplace: bool = True
) -> Union[xarray.Dataset, xarray.DataArray]:
"""
@@ -474,7 +478,7 @@ Source code for rioxarray.rioxarray
return self._set_crs(input_crs, inplace=inplace)
- def _set_crs(
+ def _set_crs(
self, input_crs: Any, inplace: bool = True
) -> Union[xarray.Dataset, xarray.DataArray]:
"""
@@ -499,7 +503,7 @@ Source code for rioxarray.rioxarray
return obj
@property
- def grid_mapping(self) -> str:
+ def grid_mapping(self) -> str:
"""
str: The CF grid_mapping attribute. 'spatial_ref' is the default.
"""
@@ -527,7 +531,7 @@ Source code for rioxarray.rioxarray
[docs]
- def write_grid_mapping(
+ def write_grid_mapping(
self, grid_mapping_name: str = DEFAULT_GRID_MAP, inplace: bool = False
) -> Union[xarray.Dataset, xarray.DataArray]:
"""
@@ -572,7 +576,7 @@ Source code for rioxarray.rioxarray
[docs]
- def write_crs(
+ def write_crs(
self,
input_crs: Optional[Any] = None,
grid_mapping_name: Optional[str] = None,
@@ -656,7 +660,7 @@ Source code for rioxarray.rioxarray
[docs]
- def estimate_utm_crs(self, datum_name: str = "WGS 84") -> rasterio.crs.CRS:
+ def estimate_utm_crs(self, datum_name: str = "WGS 84") -> rasterio.crs.CRS:
"""Returns the estimated UTM CRS based on the bounds of the dataset.
.. versionadded:: 0.2
@@ -696,10 +700,10 @@ Source code for rioxarray.rioxarray
try:
return CRS.from_epsg(utm_crs_list[0].code)
except IndexError:
- raise RuntimeError("Unable to determine UTM CRS") from None
+ raise RuntimeError("Unable to determine UTM CRS") from None
- def _cached_transform(self) -> Optional[Affine]:
+ def _cached_transform(self) -> Optional[Affine]:
"""
Get the transform from:
1. The GeoTransform metatada property in the grid mapping
@@ -722,7 +726,7 @@ Source code for rioxarray.rioxarray
[docs]
- def write_transform(
+ def write_transform(
self,
transform: Optional[Affine] = None,
grid_mapping_name: Optional[str] = None,
@@ -773,7 +777,7 @@ Source code for rioxarray.rioxarray
[docs]
- def transform(self, recalc: bool = False) -> Affine:
+ def transform(self, recalc: bool = False) -> Affine:
"""
Parameters
----------
@@ -809,7 +813,7 @@ Source code for rioxarray.rioxarray
[docs]
- def write_coordinate_system(
+ def write_coordinate_system(
self, inplace: bool = False
) -> Union[xarray.Dataset, xarray.DataArray]:
"""
@@ -869,7 +873,7 @@ Source code for rioxarray.rioxarray
[docs]
- def set_attrs(
+ def set_attrs(
self, new_attrs: dict, inplace: bool = False
) -> Union[xarray.Dataset, xarray.DataArray]:
"""
@@ -900,7 +904,7 @@ Source code for rioxarray.rioxarray
[docs]
- def update_attrs(
+ def update_attrs(
self, new_attrs: dict, inplace: bool = False
) -> Union[xarray.Dataset, xarray.DataArray]:
"""
@@ -926,7 +930,7 @@ Source code for rioxarray.rioxarray