Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jgrss/features delayed #250

Merged
merged 21 commits into from
Mar 29, 2023
24 changes: 24 additions & 0 deletions doc/source/tutorial-edit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,27 @@ The GeoWombat :func:`replace` function mimics :func:`pandas.DataFrame.replace`.
.. note::

The :func:`replace` function is typically used with thematic data.

Clipping to bounds
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is where you want this.

------------------

Geowombat's :func:`clip_by_polygon` limits the bounds of the image to match a polygon,
where the polygon can be a `GeoDatabase`, or a path to a file readable with `geopandas.read_file()`.
You can augment the clip by using a `query` on the polygon attributes, if multiple polygons
are present you can `mask_data` to fill `nan` where polygons are not present, or expand the clip
array bounds by `expand_by` pixels on each side.

.. code:: python

import geowombat as gw
from geowombat.data import l8_224078_20200518, l8_224078_20200518_polygons
import geopandas as gpd

polys = gpd.read_file(l8_224078_20200518_polygons)


with gw.open(l8_224078_20200518) as src:
src.gw.clip_by_polygon(df,
query="name == water",
mask_data=True,
expand_by=1)