Skip to content

Commit 65266d5

Browse files
authored
Re-organize documentation to list features independently of data objects (#565)
1 parent e3e69bf commit 65266d5

26 files changed

+1058
-124
lines changed

doc/source/api.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ documentation.
4747
Raster.crs
4848
Raster.transform
4949
Raster.nodata
50+
Raster.area_or_point
5051
```
5152

5253
### Derived attributes
@@ -83,8 +84,8 @@ documentation.
8384
Raster.reproject
8485
Raster.polygonize
8586
Raster.proximity
86-
Raster.value_at_coords
8787
Raster.interp_points
88+
Raster.reduce_points
8889
```
8990

9091
### Plotting
@@ -120,6 +121,7 @@ documentation.
120121
Raster.load
121122
Raster.save
122123
Raster.to_pointcloud
124+
Raster.from_pointcloud_regular
123125
Raster.to_rio_dataset
124126
Raster.to_xarray
125127
```
@@ -133,7 +135,7 @@ documentation.
133135
Raster.xy2ij
134136
Raster.ij2xy
135137
Raster.coords
136-
Raster.shift
138+
Raster.translate
137139
Raster.outside_image
138140
```
139141

@@ -265,6 +267,7 @@ And reverse operations.
265267
.. autosummary::
266268
:toctree: gen_modules/
267269
270+
raster.load_multiple_rasters
268271
raster.stack_rasters
269272
raster.merge_rasters
270273
```

doc/source/conf.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"xdem": ("https://xdem.readthedocs.io/en/stable", None),
6666
"rioxarray": ("https://corteva.github.io/rioxarray/stable/", None),
6767
"pandas": ("https://pandas.pydata.org/docs/", None),
68+
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
6869
}
6970

7071
example_path = os.path.join("../", "../", "examples")
@@ -110,7 +111,7 @@
110111
}
111112

112113
# For matplotlib figures generate with sphinx plot: (suffix, dpi)
113-
plot_formats = [(".png", 400)]
114+
plot_formats = [(".png", 500)]
114115

115116
# To avoid long path names in inheritance diagrams
116117
inheritance_alias = {
@@ -193,7 +194,8 @@ def setup(app):
193194
"⚠️ Our 0.1 release refactored several early-development functions for long-term stability, "
194195
'to update your code see <a href="https://github.com/GlacioHack/geoutils/releases/tag/v0.1.0">here</a>. ⚠️'
195196
"<br>Future changes will come with deprecation warnings! 🙂"
196-
)
197+
),
198+
"show_toc_level": 3
197199
# "logo_only": True,
198200
# "icon_links": [
199201
# {

doc/source/config.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
file_format: mystnb
3+
jupytext:
4+
formats: md:myst
5+
text_representation:
6+
extension: .md
7+
format_name: myst
8+
kernelspec:
9+
display_name: geoutils-env
10+
language: python
11+
name: geoutils
12+
---
13+
(config)=
14+
# Configuration
15+
16+
You can configure the default behaviour of GeoUtils at the package level for operations that depend on user preference
17+
(such as resampling method, or pixel interpretation).
18+
19+
## Changing configuration during a session
20+
21+
Using a global configuration setting ensures operations will always be performed consistently, even when used
22+
under-the-hood by higher-level methods (such as [Coregistration](https://xdem.readthedocs.io/en/stable/coregistration.html)),
23+
without having to rely on multiple keyword arguments to pass to subfunctions.
24+
25+
```{code-cell}
26+
import geoutils as gu
27+
# Changing default behaviour for pixel interpretation for this session
28+
gu.config["shift_area_or_point"] = False
29+
```
30+
31+
## Default configuration file
32+
33+
Below is the full default configuration file, which is updated by changes in configuration during a session.
34+
35+
```{literalinclude} ../../geoutils/config.ini
36+
:class: full-width
37+
```
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
(rasters-index)=
2-
# Rasters
1+
(data-object-index)=
2+
# Geospatial data objects
33

44
Prefer to learn by running examples? Explore our example galleries on {ref}`examples-io`, {ref}`examples-handling` and {ref}`examples-analysis`.
55

66
```{toctree}
77
:maxdepth: 2
88
99
raster_class
10+
vector_class
11+
pointcloud_class
1012
mask_class
1113
satimg_class
1214
```

doc/source/distance_ops.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
file_format: mystnb
3+
jupytext:
4+
formats: md:myst
5+
text_representation:
6+
extension: .md
7+
format_name: myst
8+
kernelspec:
9+
display_name: geoutils-env
10+
language: python
11+
name: geoutils
12+
---
13+
(distance-ops)=
14+
# Distance operations
15+
16+
Computing distance between sets of geospatial data or manipulating their shape based on distance is often important
17+
for later analysis. To facilitate this type of operations, GeoUtils implements distance-specific functionalities
18+
for both vectors and rasters.
19+
20+
```{code-cell} ipython3
21+
:tags: [remove-cell]
22+
23+
# To get a good resolution for displayed figures
24+
from matplotlib import pyplot
25+
pyplot.rcParams['figure.dpi'] = 600
26+
pyplot.rcParams['savefig.dpi'] = 600
27+
pyplot.rcParams['font.size'] = 9
28+
```
29+
30+
```{tip}
31+
It is often important to compute distances in a metric CRS. For this, reproject (with
32+
{func}`~geoutils.Raster.reproject`) to a local metric CRS (that can be estimated with {func}`~geoutils.Raster.get_metric_crs`).
33+
```
34+
35+
## Proximity
36+
37+
Proximity corresponds to **the distance to the closest target geospatial data**, computed on each pixel of a raster's grid.
38+
The target geospatial data can be either a vector or a raster.
39+
40+
{func}`geoutils.Raster.proximity` and {func}`geoutils.Vector.proximity`
41+
42+
```{code-cell} ipython3
43+
:tags: [hide-cell]
44+
:mystnb:
45+
: code_prompt_show: "Show the code for opening example files"
46+
: code_prompt_hide: "Hide the code for opening example files"
47+
48+
import matplotlib.pyplot as plt
49+
import geoutils as gu
50+
import numpy as np
51+
52+
rast = gu.Raster(gu.examples.get_path("everest_landsat_b4"))
53+
rast.set_nodata(0) # Annoying to have to do this here, should we update it in the example?
54+
vect = gu.Vector(gu.examples.get_path("everest_rgi_outlines"))
55+
```
56+
57+
```{code-cell} ipython3
58+
# Compute proximity to vector outlines
59+
proximity = vect.proximity(rast)
60+
```
61+
62+
```{code-cell} ipython3
63+
:tags: [hide-input]
64+
:mystnb:
65+
: code_prompt_show: "Show the code for plotting the figure"
66+
: code_prompt_hide: "Hide the code for plotting the figure"
67+
68+
f, ax = plt.subplots(1, 2)
69+
ax[0].set_title("Raster and vector")
70+
rast.plot(ax=ax[0], cmap="gray", add_cbar=False)
71+
vect.plot(ref_crs=rast, ax=ax[0], ec="k", fc="none")
72+
ax[1].set_title("Proximity")
73+
proximity.plot(ax=ax[1], cmap="viridis", cbar_title="Distance to outlines (m)")
74+
_ = ax[1].set_yticklabels([])
75+
plt.tight_layout()
76+
```
77+
78+
## Buffering without overlap
79+
80+
Buffering consists in **expanding or collapsing vector geometries equally in all directions**. However, this can often lead to overlap
81+
between shapes, which is sometimes undesirable. Using Voronoi polygons, we provide a buffering method with overlap.
82+
83+
{func}`geoutils.Vector.buffer_without_overlap`
84+
85+
```{code-cell} ipython3
86+
# Compute buffer without overlap from vector exterior
87+
vect_buff_nolap = vect.buffer_without_overlap(buffer_size=500)
88+
```
89+
90+
```{code-cell} ipython3
91+
:tags: [hide-input]
92+
:mystnb:
93+
: code_prompt_show: "Show the code for plotting the figure"
94+
: code_prompt_hide: "Hide the code for plotting the figure"
95+
96+
# Plot with color to see that the attributes are retained for every feature
97+
vect.plot(ax="new", ec="k", column="Area", alpha=0.5, add_cbar=False)
98+
vect_buff_nolap.plot(column="Area", cbar_title="Buffer around initial features\ncolored by glacier area (km)")
99+
```

doc/source/feature_overview.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,23 @@ kernelspec:
1616

1717
The following presents a descriptive example show-casing all core features of GeoUtils.
1818

19-
For more details, refer to the {ref}`core-index`, {ref}`rasters-index` or {ref}`vectors-index` pages.
20-
2119
```{tip}
2220
All pages of this documentation containing code cells can be **run interactively online without the need of setting up your own environment**. Simply click the top launch button!
2321
(MyBinder can be a bit capricious: you might have to be patient, or restart it after the build is done the first time 😅)
2422
2523
Alternatively, start your own notebook to test GeoUtils at [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/GlacioHack/geoutils/main).
2624
```
2725

26+
```{code-cell} ipython3
27+
:tags: [remove-cell]
28+
29+
# To get a good resolution for displayed figures
30+
from matplotlib import pyplot
31+
pyplot.rcParams['figure.dpi'] = 600
32+
pyplot.rcParams['savefig.dpi'] = 600
33+
pyplot.rcParams['font.size'] = 9
34+
```
35+
2836
## The core {class}`~geoutils.Raster` and {class}`~geoutils.Vector` classes
2937

3038
In GeoUtils, geospatial handling is object-based and revolves around {class}`~geoutils.Raster` and {class}`~geoutils.Vector`.

0 commit comments

Comments
 (0)