From fd67028718d128f9a0d7e45a855e19341b699839 Mon Sep 17 00:00:00 2001 From: Andrew Tedstone Date: Thu, 18 Jan 2024 15:55:33 +0100 Subject: [PATCH] update crop examples --- examples/handling/georeferencing/crop_raster.py | 4 ++-- examples/handling/georeferencing/crop_vector.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/handling/georeferencing/crop_raster.py b/examples/handling/georeferencing/crop_raster.py index 84aa9983..26fcba5c 100644 --- a/examples/handling/georeferencing/crop_raster.py +++ b/examples/handling/georeferencing/crop_raster.py @@ -30,7 +30,7 @@ # **First option:** using the vector as a reference to match, we reproject the raster. We simply have to pass the :class:`~geoutils.Vector` # as single argument to :func:`~geoutils.Raster.crop`. See :ref:`core-match-ref` for more details. -rast.crop(vect) +rast.crop(vect, inplace=True) # %% # Now the bounds should be the same as that of the vector (within the size of a pixel as the grid was not warped). @@ -46,7 +46,7 @@ # **Second option:** we can pass other ``crop_geom`` argument to :func:`~geoutils.Raster.crop`, including another :class:`~geoutils.Raster` or a # simple :class:`tuple` of bounds. For instance, we can re-crop the raster to be smaller than the vector. -rast.crop((rast.bounds.left + 1000, rast.bounds.bottom, rast.bounds.right, rast.bounds.top - 500)) +rast.crop((rast.bounds.left + 1000, rast.bounds.bottom, rast.bounds.right, rast.bounds.top - 500), inplace=True) rast.show(ax="new", cmap="Purples") vect.show(ref_crs=rast, fc="none", ec="k", lw=2) diff --git a/examples/handling/georeferencing/crop_vector.py b/examples/handling/georeferencing/crop_vector.py index 6c67b377..b14b2e03 100644 --- a/examples/handling/georeferencing/crop_vector.py +++ b/examples/handling/georeferencing/crop_vector.py @@ -24,7 +24,7 @@ # **First option:** using the raster as a reference to match, we crop the vector. We simply have to pass the :class:`~geoutils.Raster` as single argument to # :func:`~geoutils.Vector.crop`. See :ref:`core-match-ref` for more details. -vect.crop(rast) +vect.crop(rast, inplace=True) # %% # .. note:: @@ -47,7 +47,9 @@ # simple :class:`tuple` of bounds. bounds = rast.get_bounds_projected(out_crs=vect.crs) -vect.crop(crop_geom=(bounds.left + 0.5 * (bounds.right - bounds.left), bounds.bottom, bounds.right, bounds.top)) +vect.crop( + crop_geom=(bounds.left + 0.5 * (bounds.right - bounds.left), bounds.bottom, bounds.right, bounds.top), inplace=True +) rast.show(ax="new", cmap="Greys_r", alpha=0.7) vect.show(ref_crs=rast, fc="none", ec="tab:purple", lw=3)