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

spsample keep in candidates. #114

Open
OrdinarySK opened this issue Feb 25, 2022 · 0 comments
Open

spsample keep in candidates. #114

OrdinarySK opened this issue Feb 25, 2022 · 0 comments

Comments

@OrdinarySK
Copy link

Hello, I now want to perturb randomly generated points within a polygonal area. I've written the perturbation algorithm, but I can't guarantee that the perturbed points are still inside the polygon area. I think that when using spsample, it is guaranteed to be in candidates. I want to know how I can implement this. My own design only ensures that the xy of the perturbed points are within x_bound and y_bound respectively. Below is my code.

x_bound = bbox(candidates)[1, ] y_bound = bbox(candidates)[2, ] x_extent = x_bound[2] - x_bound[1] y_extent = y_bound[2] - y_bound[1] temp_pt[j,1] = curr_pt[j,1] + x_extent * runif(1, -0.2, 0.2) while(temp_pt[j,1] < x_bound[1] || temp_pt[j,1] > x_bound[2]){ temp_pt[j,1] = curr_pt[j,1] + x_extent * runif(1, -0.2, 0.2) } temp_pt[j,2] = curr_pt[j,2] + y_extent * runif(1, -0.2, 0.2) while(temp_pt[j,2] < y_bound[1] || temp_pt[j,2] > y_bound[2]){ temp_pt[j,2] = curr_pt[j,2] + y_extent * runif(1, -0.2, 0.2) }
7(5UDKAWON~21S(GO MTLCH

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

No branches or pull requests

1 participant