Skip to content

Commit b2f06cb

Browse files
authored
DOC: Add rioxarray and other external examples (#3757)
* DOC: Add rioxarray link to examples and add example in file IO * Add more external examples. * fix spacing for ipython docs * minor fixes * fix bad edit Co-authored-by: Deepak Cherian <[email protected]>
1 parent 01462d6 commit b2f06cb

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

doc/examples.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,12 @@ Using apply_ufunc
1717
:maxdepth: 2
1818

1919
examples/apply_ufunc_vectorize_1d
20+
21+
External Examples
22+
-----------------
23+
.. toctree::
24+
:maxdepth: 2
25+
26+
Managing raster data with rioxarray <https://corteva.github.io/rioxarray/stable/examples/examples.html>
27+
Xarray with dask <https://examples.dask.org/xarray.html>
28+
Xarray and dask on the cloud with Pangeo <http://pangeo.io/use_cases/index.html#use-cases>

doc/io.rst

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,53 @@ for an example of how to convert these to longitudes and latitudes.
759759
considered as being experimental. Please report any bug you may find
760760
on xarray's github repository.
761761

762+
763+
Additionally, you can use `rioxarray`_ for reading in GeoTiff, netCDF or other
764+
GDAL readable raster data using `rasterio`_ as well as for exporting to a geoTIFF.
765+
`rioxarray`_ can also handle geospatial related tasks such as re-projecting and clipping.
766+
767+
.. ipython::
768+
:verbatim:
769+
770+
In [1]: import rioxarray
771+
772+
In [2]: rds = rioxarray.open_rasterio('RGB.byte.tif')
773+
774+
In [3]: rds
775+
Out[3]:
776+
<xarray.DataArray (band: 3, y: 718, x: 791)>
777+
[1703814 values with dtype=uint8]
778+
Coordinates:
779+
* band (band) int64 1 2 3
780+
* y (y) float64 2.827e+06 2.826e+06 ... 2.612e+06 2.612e+06
781+
* x (x) float64 1.021e+05 1.024e+05 ... 3.389e+05 3.392e+05
782+
spatial_ref int64 0
783+
Attributes:
784+
STATISTICS_MAXIMUM: 255
785+
STATISTICS_MEAN: 29.947726688477
786+
STATISTICS_MINIMUM: 0
787+
STATISTICS_STDDEV: 52.340921626611
788+
transform: (300.0379266750948, 0.0, 101985.0, 0.0, -300.0417827...
789+
_FillValue: 0.0
790+
scale_factor: 1.0
791+
add_offset: 0.0
792+
grid_mapping: spatial_ref
793+
794+
In [4]: rds.rio.crs
795+
Out[4]: CRS.from_epsg(32618)
796+
797+
In [5]: rds4326 = rio.rio.reproject("epsg:4326")
798+
799+
In [6]: rds4326.rio.crs
800+
Out[6]: CRS.from_epsg(4326)
801+
802+
In [7]: rds4326.rio.to_raster('RGB.byte.4326.tif')
803+
804+
762805
.. _rasterio: https://rasterio.readthedocs.io/en/latest/
806+
.. _rioxarray: https://corteva.github.io/rioxarray/stable/
763807
.. _test files: https://github.com/mapbox/rasterio/blob/master/tests/data/RGB.byte.tif
764-
.. _pyproj: https://github.com/jswhit/pyproj
808+
.. _pyproj: https://github.com/pyproj4/pyproj
765809

766810
.. _io.zarr:
767811

0 commit comments

Comments
 (0)