From a286721f5d6a0f0c591427d317432244d027d0b2 Mon Sep 17 00:00:00 2001 From: snowman2 Date: Thu, 6 Feb 2020 10:13:42 -0600 Subject: [PATCH 1/5] DOC: Add rioxarray link to examples and add example in file IO --- doc/examples.rst | 1 + doc/io.rst | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/doc/examples.rst b/doc/examples.rst index 3067ca824be..31dcedcee67 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -10,6 +10,7 @@ Examples examples/visualization_gallery examples/ROMS_ocean_model examples/ERA5-GRIB-example + Managing raster data with rioxarray Using apply_ufunc ------------------ diff --git a/doc/io.rst b/doc/io.rst index e910943236f..d4a25411b56 100644 --- a/doc/io.rst +++ b/doc/io.rst @@ -759,9 +759,54 @@ for an example of how to convert these to longitudes and latitudes. considered as being experimental. Please report any bug you may find on xarray's github repository. + +Additionally, you can use `rioxarray`_ for reading in GeoTiff, netCDF or other +GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIFF. +`rioxarray`_ can also handle geospatial related tasks such as re-projecting and clipping. + +.. ipython:: + :verbatim: + + In [1]: import rioxarray + In [2]: rds = rioxarray.open_rasterio('RGB.byte.tif') + + In [3]: rds + Out[3]: + + [1703814 values with dtype=uint8] + Coordinates: + * band (band) int64 1 2 3 + * y (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06 + * x (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05 + spatial_ref int64 0 + Attributes: + STATISTICS_MAXIMUM: 255 + STATISTICS_MEAN: 29.947726688477 + STATISTICS_MINIMUM: 0 + STATISTICS_STDDEV: 52.340921626611 + transform: (300.0379266750948, 0.0, 101985.0, 0.0, -300.0417827... + _FillValue: 0.0 + scale_factor: 1.0 + add_offset: 0.0 + grid_mapping: spatial_ref + + In [4]: rds.rio.crs + Out[4]: + CRS.from_epsg(32618) + + In [5]: rds4326 = rio.rio.reproject("epsg:4326") + + In [6]: rds4326.rio.crs + Out[6]: + CRS.from_epsg(4326) + + In [7]: rds4326.rio.to_raster('RGB.byte.4326.tif') + + .. _rasterio: https://rasterio.readthedocs.io/en/latest/ +.. _rioxarray: https://corteva.github.io/rioxarray/stable/ .. _test files: https://github.com/mapbox/rasterio/blob/master/tests/data/RGB.byte.tif -.. _pyproj: https://github.com/jswhit/pyproj +.. _pyproj: https://github.com/pyproj4/pyproj .. _io.zarr: From 6d226e3a5019948ac16d4914799ca4f803d52270 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Mon, 24 Feb 2020 19:03:59 +0000 Subject: [PATCH 2/5] Add more external examples. --- doc/examples.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/examples.rst b/doc/examples.rst index 31dcedcee67..805395808e0 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -10,7 +10,6 @@ Examples examples/visualization_gallery examples/ROMS_ocean_model examples/ERA5-GRIB-example - Managing raster data with rioxarray Using apply_ufunc ------------------ @@ -18,3 +17,12 @@ Using apply_ufunc :maxdepth: 2 examples/apply_ufunc_vectorize_1d + +External Examples +----------------- +.. toctree:: + :maxdepth: 2 + + Managing raster data with rioxarray + Xarray with dask + Xarray and dask on the cloud with Pangeo From fe197b80d54d166f0ef3e7f159dc3b93e3bd2e4b Mon Sep 17 00:00:00 2001 From: snowman2 Date: Mon, 24 Feb 2020 15:17:12 -0600 Subject: [PATCH 3/5] fix spacing for ipython docs --- doc/io.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/io.rst b/doc/io.rst index d4a25411b56..4c405ca1ec9 100644 --- a/doc/io.rst +++ b/doc/io.rst @@ -768,6 +768,7 @@ GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIF :verbatim: In [1]: import rioxarray + In [2]: rds = rioxarray.open_rasterio('RGB.byte.tif') In [3]: rds From 8baa04c2df17b7c73407d06101bd170ca220e677 Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 5 Mar 2020 18:02:26 +0530 Subject: [PATCH 4/5] minor fixes --- doc/io.rst | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/doc/io.rst b/doc/io.rst index 4c405ca1ec9..9c52a390be4 100644 --- a/doc/io.rst +++ b/doc/io.rst @@ -776,9 +776,9 @@ GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIF [1703814 values with dtype=uint8] Coordinates: - * band (band) int64 1 2 3 - * y (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06 - * x (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05 + * band (band) int64 1 2 3 + * y (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06 + * x (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05 spatial_ref int64 0 Attributes: STATISTICS_MAXIMUM: 255 @@ -792,14 +792,12 @@ GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIF grid_mapping: spatial_ref In [4]: rds.rio.crs - Out[4]: - CRS.from_epsg(32618) + Out[4]: CRS.from_epsg(32618) In [5]: rds4326 = rio.rio.reproject("epsg:4326") In [6]: rds4326.rio.crs - Out[6]: - CRS.from_epsg(4326) + Out[6]: CRS.from_epsg(4326) In [7]: rds4326.rio.to_raster('RGB.byte.4326.tif') @@ -848,7 +846,7 @@ To write to a local directory, we pass a path to a directory (The suffix ``.zarr`` is optional--just a reminder that a zarr store lives there.) If the directory does not exist, it will be created. If a zarr store is already present at that path, an error will be raised, preventing it -from being overwritten. To override this behavior and overwrite an existing + store, add ``mode='w'`` when invoking ``to_zarr``. It is also possible to append to an existing store. For that, set From 4f85d1dea766cf063ba91134ff2999b301960730 Mon Sep 17 00:00:00 2001 From: dcherian Date: Thu, 5 Mar 2020 18:18:11 +0530 Subject: [PATCH 5/5] fix bad edit --- doc/io.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/io.rst b/doc/io.rst index 9c52a390be4..6064aa3568a 100644 --- a/doc/io.rst +++ b/doc/io.rst @@ -846,7 +846,7 @@ To write to a local directory, we pass a path to a directory (The suffix ``.zarr`` is optional--just a reminder that a zarr store lives there.) If the directory does not exist, it will be created. If a zarr store is already present at that path, an error will be raised, preventing it - +from being overwritten. To override this behavior and overwrite an existing store, add ``mode='w'`` when invoking ``to_zarr``. It is also possible to append to an existing store. For that, set