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

spatial perturbation #22

Open
OrdinarySK opened this issue Mar 6, 2022 · 0 comments
Open

spatial perturbation #22

OrdinarySK opened this issue Mar 6, 2022 · 0 comments

Comments

@OrdinarySK
Copy link

Hello, I coded a piece of code for multi-object spatial site sampling based on the AMOSA algorithm, but I found that my spatial perturbations didn't seem right. Can you give some advice, below is my perturbation code.

` x_extent = x_extent-iter/iterationx_extent
y_extent = y_extent-iter/iterationy_extent
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(point.in.polygon(temp_pt[j,1], temp_pt[j,2], candidates@polygons[[1]]@Polygons[[1]]@coords[,1],
                       candidates@polygons[[1]]@Polygons[[1]]@coords[,2]) != 1){
  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)
}
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