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

Create isobands inside entire polygon #2444

Closed
mumispb opened this issue Jun 9, 2023 · 12 comments · Fixed by #2768
Closed

Create isobands inside entire polygon #2444

mumispb opened this issue Jun 9, 2023 · 12 comments · Fixed by #2768

Comments

@mumispb
Copy link

mumispb commented Jun 9, 2023

I have a polygon and some measurements made inside that polygon and I would like to create isobands for the entirety of it. However, it seems interpolate only runs inside the bounding box that it creates automatically and it only encapsulates the points that I have provided with values. How could I expand it to the entire polygon?
image

This is the exact same issue in #2297. On that issue, the author has provided a working fiddle for his case https://jsfiddle.net/doug_b/xbd6Lf74/3/.

Turf.js version: 6.5.0

@lemonig
Copy link
Contributor

lemonig commented Nov 29, 2024

oh! dear.
I also encountered the same problem, a year has passed, have you solved it?
I read the source code of truf.js, interpolate method is bounded by known points, I think it should be filled with polygon as the boundary to achieve interpolation, if you have any methods or changes to solve this problem, please let me know, thank you!
image

image

@smallsaucepan
Copy link
Member

HI @mumispb and @lemonig. I think what you're asking for is to allow interpolate to process areas beyond the boundaries of the input data. Like this yes? Same points except with larger bounding box.

Screenshot 2024-11-29 at 9 41 13 PM

@lemonig
Copy link
Contributor

lemonig commented Dec 2, 2024

HI @mumispb and @lemonig. I think what you're asking for is to allow interpolate to process areas beyond the boundaries of the input data. Like this yes? Same points except with larger bounding box.

Screenshot 2024-11-29 at 9 41 13 PM

Yes, that’s exactly how you described it. Could you tell me how you figured it out? Can you help solve this problem?

@lemonig
Copy link
Contributor

lemonig commented Dec 3, 2024

HI @mumispb and @lemonig. I think what you're asking for is to allow interpolate to process areas beyond the boundaries of the input data. Like this yes? Same points except with larger bounding box.

Screenshot 2024-11-29 at 9 41 13 PM

I already know how to generate the result of the right picture, thank you, @mumispb You can do that
image
Interpolate in this area, Interpolate by yourself. That's it

@smallsaucepan
Copy link
Member

Hi @lemonig.

Could you tell me how you figured it out? Can you help solve this problem?

To make the right hand image I had to modify the Turf code to make the bounding box bigger. Will change this issue to be about adding an optional bbox option to give all users that level of control.

In the meantime, I thought of another workaround. All you would need to do is add four "dummy" points to your data, one at each corner of the bounding box you want to interpolate data within. That will trick the interpolate function into filling in the entire area.

Those four points should be as neutral as possible to not distort real points too much. You might need to experiment to find what's best. Perhaps try the average of all your points, or the minimum, for example.

It wouldn't be perfect, though should give reasonable results without having to wait for an update to Turf.

@mumispb
Copy link
Author

mumispb commented Dec 3, 2024

I have used the exact same solution as @smallsaucepan , but I have to say that the values for these extra points can be a headache, because different approaches work for different cases. It can be useful to let the users of your app define a value for these points and let them experiment. I mean, if that's your use case. I have tried using 0, 1, minimum, average, average of nearest points.

@smallsaucepan
Copy link
Member

@mumispb and @lemonig would either of you like to contribute a PR? Adding an optional bbox param to interpolate, and if provided using that rather than the bounding box of the data points?

Happy to do it if you don't have the time. Thought I'd offer the opportunity first though.

@lemonig
Copy link
Contributor

lemonig commented Dec 5, 2024

@mumispb and @lemonig would either of you like to contribute a PR? Adding an optional bbox param to interpolate, and if provided using that rather than the bounding box of the data points?

Happy to do it if you don't have the time. Thought I'd offer the opportunity first though.

I am very happy to do it, I think I can give it a try。and I suggest that IDW can add a search point radius, which can control the search radius of interpolation points when there are too many points。

@smallsaucepan
Copy link
Member

Excellent. Thanks @lemonig.

I suggest that IDW can add a search point radius, which can control the search radius of interpolation points when there are too many points

Do you mean this would be a new optional parameter? Would it keep the current behaviour (be backwards compatible) if called with default arguments?

@smallsaucepan
Copy link
Member

Note resolving this will also resolve #1031.

@lemonig
Copy link
Contributor

lemonig commented Dec 12, 2024

I have added PR to solve the problem of interpolating the specified area with bbox params.Please let me know if anything needs to be changed.

@smallsaucepan
Copy link
Member

This was resolved by the merge of #2768

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

Successfully merging a pull request may close this issue.

4 participants