Is there an EXCEL function to choose the closest points below a certain line? - excel

Suppose that we have a scattered series of data X,Y randomly spaced (in the pic they are ordered, but this doesn't matter) and a line which shows the maximum limit we are considering for a sub-application.
Is there a combination of functions to choose the closest points below the orange line? I've tried with a MAXIFS + LOOKUP, but didn't solve anything.

The formula of your line is: y=1.17*x, so you create a helper column, containing a formula like:
=IF(1.17*A3-B3>0;1.17*A3-B3;100000)
This means: calculate the difference between the line and the point if that difference is positive. In case it's negative (which means that the point is above the line), then show a value which is that large that it won't be taken into account while calculating the minimum.
You drag this formula all over the column.
You calculate the minimum of that column (one of the easy ways to do this, is using the autofilter).

Related

Distance between straight lines

I work in the oil & gas industry and I'm seeking advice about how to calculate the minimum distance between a set of wells (the wells are drawn as straight lines on a map). My goal is for each individual well to have a unique "spacing" value (measured in feet) which is basically the straight-line horizontal distance to the closest wellbore on a map. Below is a simple example of what I'm trying to accomplish (assume the pipe | symbol is a wellbore and the dashes are the distance between the wells)
|--|---|-|
In the drawing above we have 4 wells. The 1st well (starting from the far left) would have a spacing value of 2 (since there are 2 dashes to the closest well), the 2nd well would also have a value of 2 (since the closest well is the one to the far left which is two spaces away), the 3rd well would have a value of 1, and the 4th well would have a value of 1.
Now imagine that I have hundreds of these wells (each with latitude/longitude points that describe the start & end points of each well) and I have them all mapped in TIBCO Spotfire (scattered across Texas). Do you guys know if it would even be possible to automate a calculation like the above? I would also like to build in a rule that says the max distance between wells is 2640 ft (half of a mile).
Any ideas are appreciated!
I think you should be able to do this without any R or iron python.
Within Spotfire, you can calculate the distance in miles between 2 points using the formula below (substitute 6371 for 3958.756 to get the answer in kilometres).
GreatCircleDistance([Lat 1],[Lon 1],[Lat 2],[Lon 2]) * 3958.756
For your use case, you could cross join your table of locations, so that you have a row for every possible location combination, then calculate the distance between them using the formula above. After that, it should be pretty straight forward to find each wells closest pair.

Finding Distance From List Of Coordnates

looking to see if someone can suggest a site or excel method to find the distance of multiple long,lat coordinates from a one point
example: I have a starting point and 7 other coordinates, is there a way to find how far away (in KM/MI) each point is from the starting point?
Starting loction : 33.17261,-117.14571
list of coordinates
32.75827,-117.17577
32.76079,-117.18589
32.76444,-117.20174
32.59815,-117.01685
32.66387,-117.05577
32.59811,-117.01681
32.66381,-117.05571
lets assume the column they are stored in is column A starting in row 2 (assuming you have a header row). The first thing you are going to want to do is split them into their own columns so you can work with the numbers. There are a couple of ways to do this. The simplest is using the built in feature Text-to-Columns located on the Data ribbon.
Have the whole column selected when you start the process and on the first page, select Delimited.
On the second step choose "," as a delimeter and then press finish. You do not need the third step.
once that is done your data should now be sitting in two columns.
I will place the point you are referring to in C2 and D2, you can use text to columns for this part too or just type it in.
So base on information on another site (assuming its correct), take the earth as a sphere with radius, 6371 km. Place this value in E2.
Next convert your list into X and Y values using the following equations:
F2
=$E$2*COS(RADIANS($B2))*COS(RADIANS($A2))
G2
=$E$2*SIN(RADIANS($B2))*SIN(RADIANS($A2))
note that the degrees were converted to radians for use in excels trig functions
Repeat the process for you starting point coordinates and place the formulas in H2 and I2.
H2
=$E$2*COS(RADIANS($D2))*COS(RADIANS($C2))
I2
=$E$2*SIN(RADIANS($D2))*SIN(RADIANS($C2))
Finally in J2 use the following formula:
=SQRT((F2-$H$2)^2+(G2-$I$2)^2)
Copy the formulas in F2, G2, and J2 down as for as your source list goes. The values in J represent the distance between the X Y points. It does not the curvature of the earth though. Apparently there are many different models to predict this. You need one that works for your area if you want something more refined.
For geodesic grade accuracy (fraction of a mm) you can use my Excel add-in available on GitHub: https://github.com/tdjastrzebski/Vincenty-Excel, in particular VincentyInvDistance() function. The solution implements Vincenty's formulae,
Otherwise use Haversine formula but it does not provide geodesic grade results.
The topic is not that trivial, see Geodesics on an ellipsoid for more details.

Excel SLOPE function returning incorrect values

I seem to have stumbled upon a bug where the SLOPE function returns values when it shouldn't. Specifically, consider the following case (where X = 2.69896131835952):
If the X values are always the same, SLOPE is supposed to return #DIV/0!. But in the first case it returns 0, and more worryingly in the second case it returns some completely bogus number.
If we compare to other values, we can see this isn't normal behaviour:
This problem isn't fixed by using ISNUMBER to make sure to filter out empty results or similar. It can even happen to numbers with only a few decimal places (these numbers are exactly as shown):
In fact, this isn't a very rare phenomenon at all - if one uses RAND to pick a single random value for X, and several random values for Y then it only takes a few tries before one finds a dataset which SLOPE hiccups on.
My questions are as follows:
What's causing this behaviour?
For which values of X does this happen for?
The above was only in the case where the X value is the same for every point. Obviously this is easy to test for in advance, but is SLOPE trustworthy in the case where the X values are different? (I can't use LINEST because my data has gaps.)
The slope function does not always work with calculated values.
If you are having problems with slope function giving zero values, copy and paste the data used by the slope function as values first. The slope function does not always work with a column of calculated values.
I was trying to calculate the slope and determine how it changes with time and got only zero values. One of the columns I was using was a moving average of 10 pressure values in another column and the cells had the green triangle “error message” Formula Omits Adjacent Values. The calculations for this column were correct, this was just a suggestion that I was not using all the cells in the column for the calculation. I copied and pasted the column of moving averages into another column as Values and the slope function gave the correct values when I used the new column of values.
I had the same issue but it was resolved when i fixed an unrelated circular reference issue. My circular reference issue prevented any new functions referencing calculated values (rather than static values) from calculating properly.

Envelope plot in excel

I am trying to plot the envelope (maximum) values of a series of data. What I need is not the maximum value of the y-axis as the value of x-axis increase but an envelope or spectrum which joins only the maximum points as the values of x-axis increase.
My data look like:
If I ask for the maximum y-values as the values of the x-axis increase, I will get this one (the black line is the maximum of all data as x is asceding):
But I need a line which joins only the next maximum points till x=30 and then the maximum values, which descend (from x=30 to x=100). The curve I need should be smooth and not follow the values of the data but only join the next maximum.
The next curve is the envelope but only after the absolute maximum point. At the left of the absolute maximum point the envelope is not the wished one:
After posting my questions (as comments), I think the following will do what you want (here I'm assuming I understood what you need):
1) At any point along the X axis, you already know how to recognize a maximum,
2) If (1) is correct, you will take into account a maximum (i.e. make it part of the envelope curve) if and only if:
a) All the points to the right are lower than the current maximum, and/or
b) All the points to the left are lower than the current maximum.
Intuitively, this should work.
EDIT:
Assuming that data is arranged in columns, say between B and D and rows 10 to 100, define in cell E10 the following:
=IF(AND(MAX(B10,D10)>MAX(B9:D9),AND(MAX(B10,D10)>MAX(B11:D11)),MAX(B10,D10),"")
This formula will result into a value if you have a local maximum in rows 11 to 99 or blanks otherwise. Then, drag the formula till row 100 and voilà!!!
Note that the first and last point (i.e. rows 10 and 100) might yield a wrong result though. To prevent that, just alter the formula in those two rows.
Hope this is what you were looking for.

Excel average every 0.5 meters, irregular distances between data points

I have a data set that has height values every so often, like topography data in a straight line with GPS coordinates. I used the GPS coordinates and trigonometry to make a cumulative distance column. However, the distance between points varies. Sometimes its 10 cm sometimes its 13, sometimes its 40.
I would like to take the average height every 0.5 meters, but sometimes the distance column doesnt even land on a multiple of 0.5! This would mean my output column would be significantly shorter than my raw data column.
I think my main problem is I do not know what this process is called in order to Google it. Another problem is that the distances are irregular as mentioned above. Things I think may have something to do with it:
averageif?
binning? I do not want a histrogram though, just the data.
Thanks for the help and if you do not know the answer but at least know what I should be writing in the search bars that would be helpful as well. Thanks!
Perhaps this will work for you. I made up a series of distance vs height measurements and determined that a third order polynomial curve fit pretty well. (A different curve might best fit your real data, so you would have to alter the formula accordingly). I then used that formula to derive a set of new heights for the desired ditances at, in my example five unit differences.
The formula under Extrapolated heights is an ARRAY formula entered into all the cells at once. You select D2:D12, enter the formula in D2 and, hold down CTRL-SHIFT while hitting ENTER. If you did this correctly, you will have the same formula in each cell surrounded by curly braces {...}
Then you can decide how you want to "Average" the heights.

Resources