Skip to content

v.geometry: new tool (v.to.db wrapper) for more obvious access to vector geometry computation - #7329

Merged
petrasovaa merged 8 commits into
OSGeo:mainfrom
petrasovaa:v_geometry
Jul 14, 2026
Merged

petrasovaa merged 8 commits into
OSGeo:mainfrom
petrasovaa:v_geometry

Conversation

@petrasovaa

@petrasovaa petrasovaa commented Apr 18, 2026 •

Copy link
Copy Markdown
Contributor

When somebody wants to compute perimeter/lengths/bbox of vector features, it's difficult to find the tool because v.to.db's name doesn't convey that. Plus for many data science workflows printing it and putting in dataframe is easier than dealing with attribute table. The v.to.db's interface is centered around the table, e.g. column is required even when just printing. Here is a quick summary of the tool:

  • New tool v.geometry: read-only, JSON-first frontend to v.to.db for printing vector geometry metrics (area, perimeter, length, count, compactness, fractal_dimension, slope, sinuosity, azimuth, coordinates, start, end, bbox).
  • Multiple metrics in one call are dispatched in parallel (ThreadPoolExecutor, controlled by nprocs) and merged by category; results stay deterministic in metric order.
  • Output formats: json (default), csv (comma default), plain (pipe default); positional per-metric units.
  • Rejects mixing metrics from different feature-type families (area/line/point) to avoid silent cat-collision merges; count is universal.

It includes functions resolving number of cores, this is something that will need to go into a library I think, but I kept it here for now.

Before:

v.to.db map=geology option=bbox column=unused -p format=json

Instead using v.geometry:

v.geometry map=geology option=bbox

@github-actions github-actions Bot added vector Related to vector data processing Python Related code is in Python HTML Related code is in HTML module docs markdown Related to markdown, markdown files tests Related to Test Suite CMake labels Apr 18, 2026

@cwhite911 cwhite911 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.

Overall, everything looks good. I just have a few minor suggestions.

Comment thread scripts/v.geometry/v.geometry.md Resolved
Comment thread scripts/v.geometry/v.geometry.py Resolved
Comment thread scripts/v.geometry/v.geometry.py Resolved
Comment thread scripts/v.geometry/v.geometry.py Resolved
Comment thread scripts/v.geometry/v.geometry.py Resolved
@petrasovaa
petrasovaa requested a review from cwhite911 July 12, 2026 10:07
@petrasovaa
petrasovaa enabled auto-merge (squash) July 12, 2026 14:00
@petrasovaa
petrasovaa merged commit 3e84f7c into OSGeo:main Jul 14, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Jul 14, 2026
echoix pushed a commit to wenzeslaus/grass that referenced this pull request Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake docs HTML Related code is in HTML markdown Related to markdown, markdown files module Python Related code is in Python tests Related to Test Suite vector Related to vector data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants