diff --git a/docs/html/.buildinfo b/docs/html/.buildinfo index 51b04c69..0c7f2109 100644 --- a/docs/html/.buildinfo +++ b/docs/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 1cb61a7d80e7be4eb9684952b9735c30 +config: 8113f10dd074ceb5d428a956dc416810 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/html/_modules/index.html b/docs/html/_modules/index.html index f7a6016a..d3b36d63 100644 --- a/docs/html/_modules/index.html +++ b/docs/html/_modules/index.html @@ -6,7 +6,7 @@ - Overview: module code — rioxarray 0.0.12 documentation + Overview: module code — rioxarray 0.0.13 documentation @@ -26,7 +26,7 @@

Navigation

  • modules |
  • - + @@ -72,7 +72,7 @@

    Navigation

  • modules |
  • - + @@ -506,7 +506,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/html/_modules/rioxarray/crs.html b/docs/html/_modules/rioxarray/crs.html index dd653f8e..a029039e 100644 --- a/docs/html/_modules/rioxarray/crs.html +++ b/docs/html/_modules/rioxarray/crs.html @@ -6,7 +6,7 @@ - rioxarray.crs — rioxarray 0.0.12 documentation + rioxarray.crs — rioxarray 0.0.13 documentation @@ -26,7 +26,7 @@

    Navigation

  • modules |
  • - + @@ -94,7 +94,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/html/_modules/rioxarray/exceptions.html b/docs/html/_modules/rioxarray/exceptions.html index eddd53e9..9985b7d4 100644 --- a/docs/html/_modules/rioxarray/exceptions.html +++ b/docs/html/_modules/rioxarray/exceptions.html @@ -6,7 +6,7 @@ - rioxarray.exceptions — rioxarray 0.0.12 documentation + rioxarray.exceptions — rioxarray 0.0.13 documentation @@ -26,7 +26,7 @@

    Navigation

  • modules |
  • - + @@ -105,7 +105,7 @@

    Navigation

  • modules |
  • - + diff --git a/docs/html/_modules/rioxarray/rioxarray.html b/docs/html/_modules/rioxarray/rioxarray.html index dd6787db..8923c2fa 100644 --- a/docs/html/_modules/rioxarray/rioxarray.html +++ b/docs/html/_modules/rioxarray/rioxarray.html @@ -6,7 +6,7 @@ - rioxarray.rioxarray — rioxarray 0.0.12 documentation + rioxarray.rioxarray — rioxarray 0.0.13 documentation @@ -26,7 +26,7 @@

    Navigation

  • modules |
  • - + @@ -50,7 +50,6 @@

    Source code for rioxarray.rioxarray

     
     """
     import copy
    -from abc import abstractmethod
     from datetime import datetime
     
     import numpy as np
    @@ -261,12 +260,29 @@ 

    Source code for rioxarray.rioxarray

             self._crs = None
     
         @property
    -    @abstractmethod
         def crs(self):
             """:obj:`rasterio.crs.CRS`:
    -            The projection of the dataset.
    +            Retrieve projection from `xarray.DataArray` or `xarray.Dataset`
             """
    -        raise NotImplementedError
    +        if self._crs is not None:
    +            return None if self._crs is False else self._crs
    +
    +        try:
    +            # look in grid_mapping
    +            grid_mapping_coord = self._obj.attrs.get("grid_mapping", DEFAULT_GRID_MAP)
    +            try:
    +                crs_wkt = self._obj.coords[grid_mapping_coord].attrs["spatial_ref"]
    +            except KeyError:
    +                crs_wkt = self._obj.coords[grid_mapping_coord].attrs["crs_wkt"]
    +            self.set_crs(crs_wkt, inplace=True)
    +        except KeyError:
    +            try:
    +                # look in attrs for 'crs'
    +                self.set_crs(self._obj.attrs["crs"], inplace=True)
    +            except KeyError:
    +                self._crs = False
    +                return None
    +        return self._crs
     
         def _get_obj(self, inplace):
             """
    @@ -364,10 +380,7 @@ 

    Source code for rioxarray.rioxarray

                         data_obj[var].rio.update_attrs(
                             dict(grid_mapping=grid_mapping_name), inplace=True
                         )
    -        else:
    -            data_obj.rio.update_attrs(
    -                dict(grid_mapping=grid_mapping_name), inplace=True
    -            )
    +        data_obj.rio.update_attrs(dict(grid_mapping=grid_mapping_name), inplace=True)
             return data_obj
    [docs] def set_attrs(self, new_attrs, inplace=False): @@ -547,31 +560,6 @@

    Source code for rioxarray.rioxarray

             data_obj.rio.set_nodata(input_nodata, inplace=True)
             return data_obj
    - @property - def crs(self): - """:obj:`rasterio.crs.CRS`: - Retrieve projection from `xarray.DataArray` - """ - if self._crs is not None: - return None if self._crs is False else self._crs - - try: - # look in grid_mapping - grid_mapping_coord = self._obj.attrs["grid_mapping"] - try: - crs_wkt = self._obj.coords[grid_mapping_coord].attrs["spatial_ref"] - except KeyError: - crs_wkt = self._obj.coords[grid_mapping_coord].attrs["crs_wkt"] - self.set_crs(crs_wkt, inplace=True) - except KeyError: - try: - # look in attrs for 'crs' - self.set_crs(self._obj.attrs["crs"], inplace=True) - except KeyError: - self._crs = False - return None - return self._crs - @property def encoded_nodata(self): """Return the encoded nodata value for the dataset if encoded.""" @@ -1225,11 +1213,19 @@

    Source code for rioxarray.rioxarray

             """:obj:`rasterio.crs.CRS`:
                 Retrieve projection from `xarray.Dataset`
             """
    -        if self._crs is None:
    -            try:
    -                self._crs = self._obj[self.vars[0]].rio.crs
    -            except IndexError:
    -                pass
    +        if self._crs is not None:
    +            return None if self._crs is False else self._crs
    +        self._crs = super().crs
    +        if self._crs is not None:
    +            return self._crs
    +        for var in self.vars:
    +            crs = self._obj[var].rio.crs
    +            if crs is not None:
    +                self._crs = crs
    +                break
    +        else:
    +            self._crs = False
    +            return None
             return self._crs
     
     
    [docs] def reproject( @@ -1455,7 +1451,7 @@

    Navigation

  • modules |
  • - +
    diff --git a/docs/html/_sources/examples/crs_management.ipynb.txt b/docs/html/_sources/examples/crs_management.ipynb.txt index 7af5748b..92bb1bef 100644 --- a/docs/html/_sources/examples/crs_management.ipynb.txt +++ b/docs/html/_sources/examples/crs_management.ipynb.txt @@ -20,7 +20,7 @@ "source": [ "If you have opened up a dataset and the Coordinate Reference System (CRS) is able to be determined, you can access it via the `rio.crs` accessor.\n", "\n", - "#### Search order for the CRS (DataArray):\n", + "#### Search order for the CRS (DataArray and Dataset):\n", "1. Look in attributes (`attrs`) of your data array for the `grid_mapping` coordinate name.\n", " Inside the `grid_mapping` coordinate first look for `spatial_ref` and second for `crs_wkt`.\n", " This is in line with the Climate and Forecast (CF) conventions for storing the CRS.\n", @@ -28,8 +28,9 @@ "\n", "The value for the `crs` is anything accepted by `rasterio.crs.CRS.from_user_input()`\n", "\n", - "#### Search order for the CRS (Dataset):\n", - "At this time, it pulls the CRS from the first variable of the dataset. This method for accessing the CRS is not recommended." + "#### Search order for the CRS for Dataset:\n", + "If the CRS is not found using the search methods above, it also searches the `data_vars` and uses the\n", + "first valid CRS found." ] }, { @@ -153,7 +154,7 @@ "source": [ "## Setting the CRS of the Dataset\n", "\n", - "Currently, you can use the `rio.set_crs` and `rio.write_crs` methods to set the CRS on your `xarray.Dataset` or `xarray.DataArray`. However, it is recommended to do CRS operations on the `xarray.DataArray`." + "Currently, you can use the `rio.set_crs` and `rio.write_crs` methods to set the CRS on your `xarray.Dataset` or `xarray.DataArray`." ] }, { diff --git a/docs/html/_sources/history.rst.txt b/docs/html/_sources/history.rst.txt index 6117a2e3..d77191b6 100644 --- a/docs/html/_sources/history.rst.txt +++ b/docs/html/_sources/history.rst.txt @@ -1,6 +1,10 @@ History ======= +0.0.13 +------ +- Improve CRS searching for xarray.Dataset & use default grid mapping name (pull #51) + 0.0.12 ------ - Use `xarray.open_rasterio()` for `rioxarray.open_rasterio()` with xarray<0.12.3 (pull #40) diff --git a/docs/html/_static/documentation_options.js b/docs/html/_static/documentation_options.js index b562bb38..64cd7a8d 100644 --- a/docs/html/_static/documentation_options.js +++ b/docs/html/_static/documentation_options.js @@ -1,6 +1,6 @@ var DOCUMENTATION_OPTIONS = { URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), - VERSION: '0.0.12', + VERSION: '0.0.13', LANGUAGE: 'None', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', diff --git a/docs/html/authors.html b/docs/html/authors.html index 56601c7d..10698413 100644 --- a/docs/html/authors.html +++ b/docs/html/authors.html @@ -6,7 +6,7 @@ - Contributors ✨ — rioxarray 0.0.12 documentation + Contributors ✨ — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - +
    @@ -115,7 +115,7 @@

    Navigation

  • previous |
  • - +
    @@ -220,7 +220,7 @@

    Navigation

  • previous |
  • - +
    @@ -393,7 +393,7 @@

    Navigation

  • previous |
  • - +
    diff --git a/docs/html/examples/clip_box.html b/docs/html/examples/clip_box.html index 09b56746..62c02f58 100644 --- a/docs/html/examples/clip_box.html +++ b/docs/html/examples/clip_box.html @@ -6,7 +6,7 @@ - Example - Clip Box — rioxarray 0.0.12 documentation + Example - Clip Box — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - + @@ -471,7 +471,7 @@

    Navigation

  • previous |
  • - + diff --git a/docs/html/examples/clip_geom.html b/docs/html/examples/clip_geom.html index a38fe5ac..9c5b2781 100644 --- a/docs/html/examples/clip_geom.html +++ b/docs/html/examples/clip_geom.html @@ -6,7 +6,7 @@ - Example - Clip — rioxarray 0.0.12 documentation + Example - Clip — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - + @@ -551,7 +551,7 @@

    Navigation

  • previous |
  • - + diff --git a/docs/html/examples/convert_to_raster.html b/docs/html/examples/convert_to_raster.html index 9c627b61..31a36ad9 100644 --- a/docs/html/examples/convert_to_raster.html +++ b/docs/html/examples/convert_to_raster.html @@ -6,7 +6,7 @@ - Example - Convert dataset to raster (GeoTiff) — rioxarray 0.0.12 documentation + Example - Convert dataset to raster (GeoTiff) — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - + @@ -585,7 +585,7 @@

    Navigation

  • previous |
  • - + diff --git a/docs/html/examples/crs_management.html b/docs/html/examples/crs_management.html index 6e5a8245..c48ade02 100644 --- a/docs/html/examples/crs_management.html +++ b/docs/html/examples/crs_management.html @@ -6,7 +6,7 @@ - Coordinate Reference System Management — rioxarray 0.0.12 documentation + Coordinate Reference System Management — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - + @@ -249,17 +249,17 @@

    Coordinate Reference System Management

    Accessing the CRS object

    If you have opened up a dataset and the Coordinate Reference System (CRS) is able to be determined, you can access it via the rio.crs accessor.

    -
    -

    Search order for the CRS (DataArray):

    +
    +

    Search order for the CRS (DataArray and Dataset):

    1. Look in attributes (attrs) of your data array for the grid_mapping coordinate name. Inside the grid_mapping coordinate first look for spatial_ref and second for crs_wkt. This is in line with the Climate and Forecast (CF) conventions for storing the CRS.
    2. Look in the crs attribute and load in the CRS from there.

    The value for the crs is anything accepted by rasterio.crs.CRS.from_user_input()

    -
    -

    Search order for the CRS (Dataset):

    -

    At this time, it pulls the CRS from the first variable of the dataset. This method for accessing the CRS is not recommended.

    +
    +

    Search order for the CRS for Dataset:

    +

    If the CRS is not found using the search methods above, it also searches the data_vars and uses the first valid CRS found.

    [1]:
     
    @@ -371,7 +371,7 @@

    Search order for the CRS (Dataset):

    Setting the CRS of the Dataset

    -

    Currently, you can use the rio.set_crs and rio.write_crs methods to set the CRS on your xarray.Dataset or xarray.DataArray. However, it is recommended to do CRS operations on the xarray.DataArray.

    +

    Currently, you can use the rio.set_crs and rio.write_crs methods to set the CRS on your xarray.Dataset or xarray.DataArray.

    This sets the CRS on the rio accessor without modifying the xarray.Dataset or xarray.DataArray.

    diff --git a/docs/html/examples/examples.html b/docs/html/examples/examples.html index b2200463..b73a4ea8 100644 --- a/docs/html/examples/examples.html +++ b/docs/html/examples/examples.html @@ -6,7 +6,7 @@ - Usage Examples — rioxarray 0.0.12 documentation + Usage Examples — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - +
    @@ -112,7 +112,7 @@

    Navigation

  • previous |
  • - +
    @@ -471,7 +471,7 @@

    Navigation

  • previous |
  • - +
    diff --git a/docs/html/examples/reproject.html b/docs/html/examples/reproject.html index 2055b508..15e7c16f 100644 --- a/docs/html/examples/reproject.html +++ b/docs/html/examples/reproject.html @@ -6,7 +6,7 @@ - Example - Reproject — rioxarray 0.0.12 documentation + Example - Reproject — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - +
    @@ -460,7 +460,7 @@

    Navigation

  • previous |
  • - +
    diff --git a/docs/html/examples/reproject_match.html b/docs/html/examples/reproject_match.html index 98239917..3aa63d9e 100644 --- a/docs/html/examples/reproject_match.html +++ b/docs/html/examples/reproject_match.html @@ -6,7 +6,7 @@ - Example - Reproject Match — rioxarray 0.0.12 documentation + Example - Reproject Match — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - +
    @@ -541,7 +541,7 @@

    Navigation

  • previous |
  • - +
    diff --git a/docs/html/examples/transform_bounds.html b/docs/html/examples/transform_bounds.html index 1ee82239..e28982b7 100644 --- a/docs/html/examples/transform_bounds.html +++ b/docs/html/examples/transform_bounds.html @@ -6,7 +6,7 @@ - Example - Transform Bounds — rioxarray 0.0.12 documentation + Example - Transform Bounds — rioxarray 0.0.13 documentation @@ -34,7 +34,7 @@

    Navigation

  • previous |
  • - + @@ -403,7 +403,7 @@

    Navigation

  • previous |
  • - + diff --git a/docs/html/genindex.html b/docs/html/genindex.html index 24106d0d..e113ea41 100644 --- a/docs/html/genindex.html +++ b/docs/html/genindex.html @@ -7,7 +7,7 @@ - Index — rioxarray 0.0.12 documentation + Index — rioxarray 0.0.13 documentation @@ -27,7 +27,7 @@

    Navigation

  • modules |
  • - + @@ -99,11 +99,9 @@

    C

    @@ -42,46 +42,52 @@

    Navigation

    History

    -

    0.0.12

    +

    0.0.13

    -

    0.0.11

    +

    0.0.12

    + +
    +
    +

    0.0.11

    -
    -

    0.0.10

    +
    +

    0.0.10

    • Add support for opening netcdf/hdf files with rioxarray.open_rasterio (issue #32)
    • Added support for custom CRS with wkt attribute for datacube CRS support (issue #35)
    • Added rio.set_nodata(), rio.write_nodata(), rio.set_attrs(), rio.update_attrs() (issue #37)
    -
    -

    0.0.9

    +
    +

    0.0.9

    • Add rioxarray.open_rasterio (issue #7)
    -
    -

    0.0.8

    +
    +

    0.0.8

    • Fix setting nodata in _add_attrs_proj (pull #30)
    -
    -

    0.0.7

    +
    +

    0.0.7

    • Add option to do an inverted clip (pull #29)
    -
    -

    0.0.6

    +
    +

    0.0.6

    -
    -

    0.0.5

    +
    +

    0.0.5

    -
    -

    0.0.4

    +
    +

    0.0.4

    • Added ability to export data array to raster (pull #8)
    @@ -118,15 +124,16 @@

    0.0.4

    Table of Contents

    @@ -169,7 +176,7 @@

    Navigation

  • previous |
  • - +
    @@ -114,7 +114,7 @@

    Navigation

  • next |
  • - +
    @@ -135,7 +135,7 @@

    Navigation

  • previous |
  • - +
    @@ -108,7 +108,7 @@

    Navigation

  • previous |
  • - +
    @@ -103,7 +103,7 @@

    Navigation

  • modules |
  • - +
    @@ -135,7 +135,7 @@

    Navigation

  • previous |
  • - +
    @@ -214,20 +214,6 @@

    rioxarray.open_rasterio -
    -
    -crs
    -

    Retrieve projection from xarray.DataArray

    - --- - - - -
    Type:rasterio.crs.CRS
    -
    -
    encoded_nodata
    @@ -695,7 +681,7 @@

    rioxarray.open_rasterio
    crs
    -

    The projection of the dataset.

    +

    Retrieve projection from xarray.DataArray or xarray.Dataset

    @@ -1075,7 +1061,7 @@

    Navigation

  • previous |
  • - + diff --git a/docs/html/search.html b/docs/html/search.html index d29f74ab..fea47317 100644 --- a/docs/html/search.html +++ b/docs/html/search.html @@ -6,7 +6,7 @@ - Search — rioxarray 0.0.12 documentation + Search — rioxarray 0.0.13 documentation @@ -35,7 +35,7 @@

    Navigation

  • modules |
  • - + @@ -86,7 +86,7 @@

    Navigation

  • modules |
  • - +