Skip to content

spsample keep in candidates. #114

Description

@OrdinarySK

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions