Skip to content

Commit

Permalink
Incremental commit on doc
Browse files Browse the repository at this point in the history
  • Loading branch information
rhugonnet committed Jun 14, 2024
1 parent 6186e30 commit fffaf78
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 8 deletions.
23 changes: 19 additions & 4 deletions doc/source/distance_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,27 @@ vect = gu.Vector(gu.examples.get_path("everest_rgi_outlines"))
```{code-cell} ipython3
# Compute proximity to vector outlines
proximity = vect.proximity(rast)
proximity.plot(cmap="viridis", cbar_title="Proximity (m)")
```

```{code-cell} ipython3
:tags: [hide-input]
:mystnb:
: code_prompt_show: "Show the code for plotting the figure"
: code_prompt_hide: "Hide the code for plotting the figure"
f, ax = plt.subplots(1, 2)
ax[0].set_title("Raster and vector")
rast.plot(ax=ax[0], cmap="gray", add_cbar=False)
vect.plot(ref_crs=rast, ax=ax[0], ec="k", fc="none")
ax[1].set_title("Proximity")
proximity.plot(ax=ax[1], cmap="viridis", cbar_title="Distance to outlines (m)")
_ = ax[1].set_yticklabels([])
plt.tight_layout()
```

## Buffering without overlap

Buffering consists in expanding vector geometries equally in all directions. However, this can often lead to overlap
Buffering consists in **expanding or collapsing vector geometries equally in all directions**. However, this can often lead to overlap
between shapes, which is sometimes undesirable. Using Voronoi polygons, we provide a buffering method with overlap.

{func}`geoutils.Vector.buffer_without_overlap`
Expand All @@ -72,5 +87,5 @@ between shapes, which is sometimes undesirable. Using Voronoi polygons, we provi
vect_buff_nolap = vect.buffer_without_overlap(buffer_size=500)
# Plot with color to see that the attributes are retained for every feature
vect.plot(ax="new", ec="k", column="Area", alpha=0.5, add_cbar=False)
vect_buff_nolap.plot(column="Area", cbar_title="Glacier area (km)")
```
vect_buff_nolap.plot(column="Area", cbar_title="Buffer around initial features\ncolored by glacier area (km)")
```
2 changes: 1 addition & 1 deletion doc/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GeoUtils ``v0.1`` is released, with most features drafted 3 years ago now finali

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

GeoUtils is built on top of core geospatial packages (Rasterio, GeoPandas) and numerical packages
GeoUtils is built on top of core geospatial packages (Rasterio, GeoPandas, PyProj) and numerical packages
(NumPy, Xarray, SciPy) to provide **consistent higher-level functionalities at the interface of raster, vector and point
cloud objects** (such as match-reference reprojection, point interpolation or gridding).

Expand Down
8 changes: 8 additions & 0 deletions doc/source/pointcloud_class.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
(point-cloud)=
# The georeferenced point cloud ({class}`~geoutils.PointCloud`)

Coming soon!

In the meantime, most point cloud operations (for instance in {ref}`raster-vector-point`) return a
{class}`~geoutils.Vector` with only point geometries and a specific `data_column_name` corresponding to the point
cloud values.



52 changes: 49 additions & 3 deletions doc/source/raster_vector_point.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,22 @@ vect = gu.Vector(gu.examples.get_path("everest_rgi_outlines"))
```{code-cell} ipython3
# Rasterize the vector features based on their glacier ID number
rasterized_vect = vect.rasterize(rast)
rasterized_vect.plot(ax="new", cmap="viridis", cbar_title="Feature index")
```

```{code-cell} ipython3
:tags: [hide-input]
:mystnb:
: code_prompt_show: "Show the code for plotting the figure"
: code_prompt_hide: "Hide the code for plotting the figure"
f, ax = plt.subplots(1, 2)
ax[0].set_title("Raster and vector")
rast.plot(ax=ax[0], cmap="gray", add_cbar=False)
vect.plot(ref_crs=rast, ax=ax[0], ec="k", fc="none")
ax[1].set_title("Rasterized vector")
rasterized_vect.plot(ax=ax[1], cmap="viridis", cbar_title="Feature index")
_ = ax[1].set_yticklabels([])
plt.tight_layout()
```

### Create mask
Expand All @@ -72,7 +87,22 @@ Mask creation from a vector **is a rasterization of all vector features that onl
```{code-cell} ipython3
# Create a boolean mask from all vector features
mask = vect.create_mask(rast)
mask.plot(ax="new", cbar_title="Glacierized areas")
```

```{code-cell} ipython3
:tags: [hide-input]
:mystnb:
: code_prompt_show: "Show the code for plotting the figure"
: code_prompt_hide: "Hide the code for plotting the figure"
f, ax = plt.subplots(1, 2)
ax[0].set_title("Raster and vector")
rast.plot(ax=ax[0], cmap="gray", add_cbar=False)
vect.plot(ref_crs=rast, ax=ax[0], ec="k", fc="none")
ax[1].set_title("Mask from vector")
mask.plot(ax=ax[1], cbar_title="Intersects vector (1=yes, 0=no)")
_ = ax[1].set_yticklabels([])
plt.tight_layout()
```

It returns a {class}`~geoutils.Mask`, a georeferenced boolean raster (or optionally, a boolean NumPy array), which
Expand All @@ -96,7 +126,23 @@ the targets are implicitly the valid values of the mask.
rasterized_vect.set_mask(rasterized_vect == 0)
# Polygonize all non-zero values
vect_repolygonized = rasterized_vect.polygonize()
vect_repolygonized.plot(ax="new", column="id", fc="none", cbar_title="Feature index")
```

```{code-cell} ipython3
:tags: [hide-input]
:mystnb:
: code_prompt_show: "Show the code for plotting the figure"
: code_prompt_hide: "Hide the code for plotting the figure"
f, ax = plt.subplots(1, 2)
ax[0].set_title("Raster (vector\n rasterized above)")
rasterized_vect.plot(ax=ax[1], cmap="viridis", cbar_title="Feature index")
vect.plot(ref_crs=rast, ax=ax[0], ec="k", fc="none")
ax[1].set_title("Polgonized raster")
vect_repolygonized.plot(ax=ax[1], column="id", fc="none", cbar_title="Feature index")
_ = ax[1].set_yticklabels([])
plt.tight_layout()
```

## Raster–point operations
Expand Down

0 comments on commit fffaf78

Please sign in to comment.