Skip to content

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

Open
petrasovaa wants to merge 3 commits intoOSGeo:mainfrom
petrasovaa:v_geometry
Open

v.geometry: new tool (v.to.db wrapper) for more obvious access to vector geometry computation#7329
petrasovaa wants to merge 3 commits intoOSGeo:mainfrom
petrasovaa:v_geometry

Conversation

@petrasovaa
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.to.db 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
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.

1 participant