I have two endpoint GPS locations and between these two points are several other points (for example 1000 points) which are unevenly spaced. My challenge is to write a code which can spread these points evenly between the two extreme GPS points which are acting as the boundary points.
I will like you all to suggest to me how to proceed.
Notes:
Boundary points: [38.77813955, -1.833538909] and [38.77202007, -1.842456068]
Number of arbitrary points in between the boundary point = 1000
I look forward to receiving feedback soon and thanks in advance.
What if you do something like:
section_width <- (boundary_max - boundary_min)/ how many divides you want?
Then do a seq(boundary_min,boundary_max,section_width)?
Hope this makes sense?
There is also a very useful function called st_make_grid that is part of the sf package, worthwhile investigating that.
thanks for the reply!
since the extreme points has both longitude and latitude, which of these two figures do I provide for the "boundary_max and boundary_min" you stated.?
ah I miss understood at first.
I see what you need.
We would need to do a little bit of math to get this done.
y = mx + c
To generate the coordinates needed.
It is means to generate the coordinates of the line between the two points.
The way I would approach it is to find the m, which is the gradient (delta -y / delta - x).
You can the derive the c.
now you can start generating the code from the closet point.
But it means we'd need to know a step change (based on the number of points you want) between the x coordinates.
So now we now all the x coordinates, now we apply the for formula to each of those x's.
That will then generate the y's and in that way we have the coordinates for each point.
what if I have several of these boundary coordinates (e.g. 20-pairs); do I have to repeat this code 20-times? Or there is a way of piping all the 20-pairs so that after running the code once, I can generate 20-sets of points with each corresponding to one of the boundary coordinates pairs.
Thanks in advance