-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jgrss
committed
Jul 27, 2020
1 parent
88355e7
commit ff6b180
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.. _tutorial-edit: | ||
|
||
Editing rasters | ||
=============== | ||
|
||
Setting 'no data' values | ||
------------------------ | ||
|
||
The :func:`xarray.DataArray.where` function masks data by setting nans, as demonstrated by the example below. | ||
|
||
.. code:: python | ||
import geowombat as gw | ||
from geowombat.data import l8_224078_20200518 | ||
# Zeros are replaced with nans | ||
with gw.open(l8_224078_20200518) as src: | ||
data = src.where(src != 0) | ||
Setting 'no data' values with scaling | ||
------------------------------------- | ||
|
||
In GeoWombat, we use :func:`xarray.where` and :func:`xarray.DataArray.where` along with optional scaling in the :func:`set_nodata` function. In this example, we set zeros as 65535 and scale all other values from a [0,10000] range to [0,1]. | ||
|
||
.. code:: python | ||
import geowombat as gw | ||
from geowombat.data import l8_224078_20200518 | ||
# Set the 'no data' value and scale all other values | ||
with gw.open(l8_224078_20200518) as src: | ||
data = src.gw.set_nodata(0, 65535, (0, 1), 'float64', scale_factor=0.0001) | ||
Replace values | ||
-------------- | ||
|
||
The GeoWombat :func:`replace` function mimics :func:`pandas.DataFrame.replace`. | ||
|
||
.. code:: python | ||
import geowombat as gw | ||
from geowombat.data import l8_224078_20200518 | ||
# Replace 1 with 10 | ||
with gw.open(l8_224078_20200518) as src: | ||
data = src.gw.replace({1: 10}) | ||
.. note:: | ||
|
||
The :func:`replace` function is typically used with thematic data. |
ff6b180
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that looks good. Not sure if you have any control here, but I am thinking that having the accessor class methods hidden in the API reference might make things confusing for nubes like me.
I tried looking it up, maybe .. autosummary:: would do it?
ff6b180
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will merge this and look into the accessor API.
There are some methods that are accessor-only and not accessible via the geowombat interface. For example, you can do:
but you can't do