Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/getting_started/crs_management.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1082,9 +1082,9 @@
"source": [
"## Setting the transform of the dataset\n",
"\n",
"The transform can be calculated from the coordinates of your data.\n",
"This method is useful if your netCDF file does not have coordinates present.\n",
"Use the `rio.write_transform` method to set the transform on your `xarray.Dataset` or `xarray.DataArray`.\n",
"Use `rio.write_transform()` to store an affine transform on an `xarray.Dataset` or `xarray.DataArray`. This is useful for rasters without explicit spatial coordinates.\n",
"\n",
"For an axis-aligned raster with one-dimensional `x` and `y` coordinates, `rio.transform()` derives the origin from the pixel centers. To change the georeferencing, update the coordinates to match the intended transform as well as writing the transform metadata.\n",
"\n",
"- [rio.write_transform()](../rioxarray.rst#rioxarray.rioxarray.XRasterBase.write_transform)\n",
"- [rio.transform()](../rioxarray.rst#rioxarray.rioxarray.XRasterBase.transform)"
Expand Down
1 change: 1 addition & 0 deletions docs/history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ History

Latest
------
- DOC: Clarify how ``rio.write_transform()`` metadata and spatial coordinates affect ``rio.transform()`` (#698)

0.25.1
------
Expand Down
16 changes: 14 additions & 2 deletions rioxarray/rioxarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ def write_transform(
For CF convention, this writes the GeoTransform to the dataset where GDAL can read it in.
https://gdal.org/drivers/raster/netcdf.html#georeference

To change the georeferencing of an axis-aligned grid with explicit x and y
coordinates, update the pixel centers to match the intended transform as
well. See :meth:`transform` for how the accessor derives the origin and
resolution.

Parameters
----------
transform: affine.Affine, optional
Expand Down Expand Up @@ -426,11 +431,18 @@ def write_transform(

def transform(self, recalc: bool = False) -> Affine:
"""
Return the affine transform of the raster.

For an axis-aligned grid with one-dimensional spatial coordinates, the origin is
derived from the x and y pixel centers. By default the stored transform,
when available, supplies the resolution. Grids without spatial coordinates
use the stored transform when available.

Parameters
----------
recalc: bool, optional
If True, it will re-calculate the transform instead of using
the cached transform.
If True, calculate the resolution from the spatial coordinates when
possible. Rotated or non-rectilinear grids use their stored transform.

Returns
-------
Expand Down