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

v.rast.move: Move points by values from raster map #877

Merged
merged 10 commits into from
Jul 19, 2023

Conversation

wenzeslaus
Copy link
Member

@wenzeslaus wenzeslaus commented Mar 17, 2023

Move of vector features positions by X and Y values given in two raster maps. This can move linear features without breaking the visual connection as points falling into the same raster cell are shifted by the same value.

The name is v.rast.move because it moves vector using raster values (operates on vectors but the big deal is that it is using raster to do the moving). Alternative name would be v.rast.displacement. Original name was v.move.points.

The one example included now shows the principle, moves in X direction both ways depending on the raster values. My use case is randomizing a set of lines (connected and not connected).

Unlike v.perturb which moves points randomly, this works on lines and keeps the values at a given cell. Unlike v.transform combined with raster values in attribute columns, this operates on individual points in the line, not on the whole line.

Copies first category, assumes layer 1. Drops attributes.

Handles null values and extent mismatch. Warns about the nulls by default. Warns when integers are used (different null check is needed but not implemented).

WIP code for move of vector features positions by X and Y values given in two raster maps. This can move linear features without breaking the visual connection as points falling into the same raster cell are shifted by the same value.

Alternative name would be v.rast.move because the big deal is that it is using raster to do the moving.

The one example included now shows the principle, moves in X direction both ways depending on the raster values. My use case is randomizing a set of lines (connected and not connected).

Feedback welcome.
@wenzeslaus wenzeslaus added the new addon PR contains a new addon or issue proposes one label Mar 17, 2023
@wenzeslaus wenzeslaus added the Python Related code is in Python label Jul 10, 2023
@wenzeslaus wenzeslaus marked this pull request as ready for review July 10, 2023 20:38
@wenzeslaus wenzeslaus changed the title v.move.points: Move points by values from raster map v.rast.move: Move points by values from raster map Jul 10, 2023
@wenzeslaus
Copy link
Member Author

I renamed the module from v.move.points to v.rast.move because it moves vector using raster values (operates on vectors but the big deal is that it is using raster to do the moving).

Tests are included, use pytest, and run locally. Example in the documentation is included, image is generated by a notebook. Pylint mostly passes locally.

Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

Looks like it works on lines only? What happens with areas or points? Consider documenting and adding a check.

@wenzeslaus
Copy link
Member Author

...lines only? ...

Right, it works only for lines. Other types would be a reasonable extension. Points are easy to do without this tool.

I added a check which ignore other types and explained the behavior in the documentation. I also added a test which tests for this behavior.

@wenzeslaus wenzeslaus merged commit a504f5e into OSGeo:grass8 Jul 19, 2023
6 checks passed
@wenzeslaus wenzeslaus deleted the add-v_move_points branch July 19, 2023 00:53
cwhite911 pushed a commit to cwhite911/grass-addons that referenced this pull request Sep 19, 2023
Move of vector features positions by X and Y values given in two raster maps. This can move linear features without breaking the visual connection as points falling into the same raster cell are shifted by the same value.

The name is v.rast.move because it moves vector using raster values (operates on vectors but the big deal is that it is using raster to do the moving). Alternative name would be v.rast.displacement. Original name was v.move.points.

The one example included now shows the principle, moves in X direction both ways depending on the raster values. My use case is randomizing a set of lines (connected and not connected).

Unlike v.perturb which moves points randomly, this works on lines and keeps the values at a given cell. Unlike v.transform combined with raster values in attribute columns, this operates on individual points in the line, not on the whole line.

Copies first category, assumes layer 1. Drops attributes. 

Handles null values and extent mismatch. Warns about the nulls by default. Warns when integers are used (different null check is needed but not implemented).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new addon PR contains a new addon or issue proposes one Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants