Skip to content

Add vector data analysis tutorial#136

Open
Valyrian-Code wants to merge 2 commits into
OSGeo:mainfrom
Valyrian-Code:add-vector-analysis-tutorial
Open

Add vector data analysis tutorial#136
Valyrian-Code wants to merge 2 commits into
OSGeo:mainfrom
Valyrian-Code:add-vector-analysis-tutorial

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

Adds a new beginner/intermediate tutorial on vector data analysis — the tutorial
set currently has no dedicated vector-focused tutorial, so this fills that gap and
covers the operations users reach for most often.

What it covers

Using the North Carolina schools_wake (points), roadsmajor (lines), and
zipcodes_wake (areas), it works through a single "school accessibility" example:

  1. Exploring features and attributes — v.info, v.db.select
  2. Selecting by attributev.extract (the 95 elementary schools)
  3. Bufferingv.buffer (a 500 m road corridor)
  4. Selecting by locationv.select (the 15 elementary schools within the corridor)
  5. Overlayv.overlay (road corridor intersected with ZIP areas)
  6. Counting per areav.vect.stats + a d.vect.thematic choropleth of schools per ZIP

Details

  • Uses the standard North Carolina sample dataset and the grass.tools API (GRASS 8.5), consistent with the recent NumPy/Landlab tutorial.
  • All code was run against GRASS 8.5; the figures are real outputs of the workflow, and the tutorial renders cleanly with Quarto (eval: false).
  • Categories: vector, beginner, intermediate, Python.
  • Cross-links to the Thematic Maps and Terrain/DEMs tutorials.

Feedback on scope, the choice of example, or wording is very welcome.

New beginner/intermediate tutorial covering the core vector toolkit:
- exploring features and attributes (v.info, v.db.select)
- selecting by attribute (v.extract) and by location (v.select)
- buffering (v.buffer) and overlaying (v.overlay) layers
- counting features per area (v.vect.stats) for a thematic map

Worked example uses the North Carolina schools, roads, and ZIP codes,
and the grass.tools API (GRASS 8.5).
Categories: vector, beginner, intermediate, Python.
Copilot AI review requested due to automatic review settings July 4, 2026 19:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@veroandreo veroandreo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The content is ok for an intro tutorial on basic vector operations. All images need to be fixed, though. Black background does not look nice and they are too big. See other suggestions below.

@@ -0,0 +1,279 @@
---
title: "Vector Data Analysis with GRASS"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
title: "Vector Data Analysis with GRASS"
title: "Basic Vector Data Analysis with GRASS"

- **select by attribute** with [v.extract](https://grass.osgeo.org/grass-stable/manuals/v.extract.html),
- **buffer** features with [v.buffer](https://grass.osgeo.org/grass-stable/manuals/v.buffer.html),
- **select by location** with [v.select](https://grass.osgeo.org/grass-stable/manuals/v.select.html),
- combine layers with [v.overlay](https://grass.osgeo.org/grass-stable/manuals/v.overlay.html), and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

v.overlay combines when we do the union; I would say "perform spatial operations with v.overlay", instead

- combine layers with [v.overlay](https://grass.osgeo.org/grass-stable/manuals/v.overlay.html), and
- count features per area with [v.vect.stats](https://grass.osgeo.org/grass-stable/manuals/v.vect.stats.html).

![Number of schools per ZIP code area in Wake County, from few (light) to many (dark).](images/thumbnail.webp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'd remove this image from here as it is generated below.

Comment on lines +54 to +55
[Get started](https://grass-tutorials.osgeo.org/content/tutorials/get_started/fast_track.html)
tutorials. Every step also works from the GRASS GUI or command line — just use the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
[Get started](https://grass-tutorials.osgeo.org/content/tutorials/get_started/fast_track.html)
tutorials. Every step also works from the GRASS GUI or command line — just use the
[Get started](https://grass-tutorials.osgeo.org/content/tutorials/get_started/fast_track_grass_and_python.html)
tutorial. Every step also works from the GRASS GUI or command line — just use the

tool name (for example `v.buffer`) with the same parameters.
:::

::: {.callout-note title="GRASS version"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To avoid callout boxes cluttering (3 of them, one right after the other doesn't look nice), move this callout below the setup code block

```

```{python}
attr_map = gj.Map(width=800)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same comment as above regarding images. Also, consider enhancing the scale bar or placing it differently, so it does not overlap the map features.

area maps with set operations. With `operator=and` we get the **intersection** — the
part of the road corridor that falls within each ZIP code area. The output keeps the
attributes of both inputs, so you could, for example, measure how much of each ZIP
code is within reach of a major road.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be nice to actually show how to estimate how much area of each ZIP is within reach of a major road.

A common summary is "how many points fall in each area?"
[v.vect.stats](https://grass.osgeo.org/grass-stable/manuals/v.vect.stats.html) counts
the points of one map within the areas of another and writes the result to the area
map's attribute table. We first copy the ZIP codes with

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
map's attribute table. We first copy the ZIP codes with
map's attribute table. We first create a copy of the ZIP codes map with

- **buffering** (`v.buffer`) and **overlaying** (`v.overlay`) layers, and
- **counting** points per area (`v.vect.stats`) for a thematic map.

These operations combine into most vector workflows. To turn results like the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
These operations combine into most vector workflows. To turn results like the
The operations described here are common in most vector workflows. To turn results like the

Comment on lines +277 to +279
[Making Thematic Maps](../thematic_maps/thematic_maps.qmd). To bring raster terrain
into the analysis, see
[Visualizing and Modeling Terrain from DEMs in GRASS](../terrain_and_DEMs/GRASS_terrain.qmd).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
[Making Thematic Maps](../thematic_maps/thematic_maps.qmd). To bring raster terrain
into the analysis, see
[Visualizing and Modeling Terrain from DEMs in GRASS](../terrain_and_DEMs/GRASS_terrain.qmd).

As there's no specific suggestion on how to connect this tutorial with the terrain one, I suggest to remove the sentence about raster terrain.

- regenerate figures with white background, smaller size (width 500),
  and a legible scale bar (white background box)
- retitle to "Basic Vector Data Analysis with GRASS"
- show the attribute table (v.db.select JSON -> pandas) before selecting
  on GLEVEL, so the selection is motivated
- add an area-within-reach computation (v.to.db + grouped db.select) to
  the overlay section
- reword the v.overlay intro bullet; move the GRASS-version callout below
  the setup code to avoid stacked callouts
- fix the get-started link to the Python quick start
- drop the unmotivated terrain cross-link; minor wording fixes
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review, @veroandreo! I've pushed an update addressing all of it:

  • Images: the transparent areas were rendering as a black background — regenerated all figures composited onto white, at a smaller size (width=500), with the scale bar on a white background box so it stays legible and clear of the features.
  • Attribute table first: added v.db.select ... format=json read into a pandas table, so the GLEVEL selection is motivated by what's actually in the data (and it shows the handy JSON-to-table trick).
  • Overlay: added an area-within-reach computation (v.to.db + grouped db.select) reporting how much of each ZIP code lies within 500 m of a major road.
  • Retitled to "Basic Vector Data Analysis with GRASS", reworded the v.overlay bullet, moved the GRASS-version callout below the setup code, fixed the get-started link, removed the duplicate intro image and the terrain cross-link, and applied the wording suggestions.

Let me know if you'd like any further changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants