Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.to.vect: new flag to re-center centroids #4690

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

metzm
Copy link
Contributor

@metzm metzm commented Nov 12, 2024

r.to.vect creates centroids that are often located near boundaries and not in the center of the areas. This PR adds a new -c flag to re-calculate the position of centroids with Vect_get_point_in_area() as also used by e.g. v.in.ogr.

new_centroids

Red: original centroids calculated by r.to.vect, blue: re-centered centroids with r.to.vect -c

@metzm metzm added enhancement New feature or request vector Related to vector data processing raster Related to raster data processing C Related code is in C labels Nov 12, 2024
@metzm metzm added this to the 8.5.0 milestone Nov 12, 2024
@metzm metzm requested a review from neteler November 12, 2024 15:45
@github-actions github-actions bot added HTML Related code is in HTML module docs labels Nov 12, 2024
@neteler
Copy link
Member

neteler commented Nov 12, 2024

A question: Is re-calculating the positions of the centroids computationally intensive (say, what is the expected slow-down)? I ask because it sound that this new flag might even be(come) the default behavior.

@metzm
Copy link
Contributor Author

metzm commented Nov 13, 2024

A question: Is re-calculating the positions of the centroids computationally intensive (say, what is the expected slow-down)? I ask because it sound that this new flag might even be(come) the default behavior.

At least for the vector boundary_county from the NC dataset with 4173 centroids, the difference in computional time is not measurable (< 0.05 seconds). The actual vectorization should always take magnitudes more time than any recalculation of the centroids.

As a guideline on how much time calculation of centroids takes, you can have a look at the progress of v.in.ogr with a large vector, specifically the parts "Finding centroids for OGR layer ..." and "Writing centroids..."

@metzm
Copy link
Contributor Author

metzm commented Nov 13, 2024

There is no simple answer to the increase in computational time: for a large computational region and few areas, the increase will not be noticeable. For a small computational region and many areas, there might be some increase in computational time, but that should not be more than 10% longer, rather 1 - 5% percent longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C docs enhancement New feature or request HTML Related code is in HTML module raster Related to raster data processing vector Related to vector data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants