Drilling and completing horizontal wells is a complex task requiring many decisions around well design, landing zone selection, well spacing, completion design… and the list goes on. We can add well orientation to the list. In this context we’ll define well orientation as the direction in which the horizontal section is laying, from 0-360 deg. More specifically, the number of degrees the botthom hole location is rotated from the surface location, with 0 deg at true north.

Just taking a snapshot of the Delaware Basin shows there are many orientations. In order to determine if this, combined with other variables such as number of wells per section, affects production, first we need to calculate the orientation.

In this post I’ll explain how to quickly calculate well orientation for a large group of wells, using Spotfire for the math and visualization and Petro.ai as the data integration source. Future posts will try to determine if orientation influences well performance. Here are the steps we’ll take:

- Load the data
- Visualize well sticks on a map
- Classify direction of well orientation (NE, SE, SW, NW)
- Calculate degrees of well orientation, from 0-360
- Visualize the results

Follow along using our Spotfire template: https://exchange.ai/downloads/calculate-wellbore-orientation/

## Loading the Data

For this example, we’ll use a group of about 17,000wells in the Delaware Basin. This data is already hooked up in my Petro.ai system, so loading it into Spotfire is as easy as selecting a well group and clicking Refresh on the Get Well action in the PetroPanel. If you’re using Petro.ai, you can add a new action or refresh configured actions to load your data. We can calculate well orientation with public well header data using the Well ID, surface and bottom hole coordinates.

I’ve also loaded the world stress map to overlay the localized stress orientations. To learn more about the WSM, check out this post: https://datashoptalk.com/load-world-stress-map-into-spotfire/.

## Classify Orientation Direction

For each well, we’ll assume an origin at the surface hole location (approximate heel location), and the endpoint at the bottom hole location (toe). Then connect the dots to draw a line, or well stick. I realize no wells follow this path exactly, but it simplifies the calculation and shouldn’t affect the result. To see how we drew the well sticks, check out this blog: https://www.datafuel.co/2018/02/24/how-to-draw-wellbore-laterals-in-spotfire/.

Now let’s classify the well direction into 4 groups, NE, SE, SW & NW**,** using calculated columns. It’s easiest to define the N/S direction in one column, the E/W direction in another column, and then concatenate the 2 directions into a 3^{rd} column. You could also write one expression to reduce the number of columns. To add a calculated column, click Insert > Calculated column, and then paste in the expressions below.

Thinking in terms of quadrants also simplifies the angle calculations in the next step.

### Calc Column 1: NS_Dir

This column classifies the direction as either North or South.

`case `

when [bottomHoleLoc.latitude]>[surfaceLoc.latitude] then "N"

when [bottomHoleLoc.latitude]<[surfaceLoc.latitude] then "S"

end

### Calc Column 2: EW_Dir

This column classifies the direction as either East or West.

`case`

when [bottomHoleLoc.longitude]>[surfaceLoc.longitude] then "E"

when [bottomHoleLoc.longitude]<[surfaceLoc.longitude] then "W"

end

### Calc Column 3: Orientation_Direction

This column concatenates the NS_Dir with the EW_Dir to show which quadrant the toe falls in.

`Concatenate([NS_Dir] , [EW_Dir])`

Now that each well has been classified, we can summarize the results in a cross table. You may notice that not every well has both directions in the *Orientation_Direction* column – this is due to missing coordinates. I’ve filtered these out to clean up the results.

Now let’s color the well sticks on the map using the *Orientation_Direction* column just added. Use this expression in the Color By selector:

`UniqueConcatenate([Well_Header].[Orientation_Direction])`

## Calculate Orientation Degrees

Now that we’ve defined which quadrant each well is in, we’ll calculate the azimuth, which is the horizontal angle measured clockwise starting true north (0 deg). We can also generalize the direction from 0-180 degrees and ignore the heel/toe placement. I’ll show both calculations below for the 0-360 and 0-180 orientation. The coordinate reference system (CRS) doesn’t matter here since we’re dividing, assuming the surface and bottom hole coordinates are in the same CRS.

To calculate the angles, we must think back to our trigonometry days using the handy acronym SOH CAH TOA. Google “SOHCAHTOA” for a quick refresher. Here’s a great example I pulled from https://www.onlinemathlearning.com/trigonometry-problems.html:

Thinking in terms of a wellbore, the lateral length is the hypotenuse, but we’re currently missing the “opposite” and “adjacent” values. We can easily calculate these as the Y & X distances from surface to buttonhole locations, where Delta_X is the longitude offset and Delta_Y is the latitude offset.

### Calc Column 4: Delta_X

`Abs([surfaceLoc.longitude] - [bottomHoleLoc.longitude])`

### Calc Column 5: Delta_Y

`Abs([surfaceLoc.latitude] - [bottomHoleLoc.latitude])`

Now we have all the pieces for our orientation calculation! There are several ways to calculate the degrees using SOHCAHTOA, but I’ve decided to use arc tangent (ArcTAN) for each angle to be consistent. More importantly, by using ArcTAN we don’t need the lateral length, which is sometimes missing from public data or measured inconsistently. Let’s use a Spotfire CASE statement, our calculated columns (*Orientation_Direction* Delta_X, & Delta_Y), and a little trig. Note that Spotfire calculates angles in radians, so we need to convert to degrees (deg = rad*(180/pi)). Here’s the expression:

### Calc Column 6: Orientation_Degrees_360

`case`

when [Orientation_Direction]="NE" then ATan([Delta_X] / [Delta_Y]) * (180 / PI())

when [Orientation_Direction]="SE" then (ATan([Delta_Y] / [Delta_X]) * (180 / PI())) + 90

when [Orientation_Direction]="SW" then (ATan([Delta_Y] / [Delta_X]) * (180 / PI())) + 180

when [Orientation_Direction]="NW" then 365 - (ATan([Delta_X] / [Delta_Y]) * (180 / PI()))

end

### Calc Column 7: Orientation_Degrees_180

If you just want to see the orientation from 0-180 degrees (ignoring heel/toe placement), the expression is similar. Just swap a few X & Ys and remove some of the angle additions:

`case `

when [Orientation_Direction]="NE" then ATan([Delta_X] / [Delta_Y]) * (180 / PI())

when [Orientation_Direction]="SE" then (ATan([Delta_Y] / [Delta_X]) * (180 / PI())) + 90

when [Orientation_Direction]="SW" then ATan([Delta_X] / [Delta_Y]) * (180 / PI())

when [Orientation_Direction]="NW" then (ATan([Delta_Y] / [Delta_X]) * (180 / PI())) + 90

end

## Results

Now that we’ve calculated the orientation angle for each well, let’s summarize the results for our wells in the Delaware Basin. Here’s an easy way to interpret the chart: the wells falling on the edges of the histogram (close to 0 and 360 degrees) are approximately vertically oriented, the wells centered around 180 and 270 degrees are more horizontally oriented, with a lot of variation across all angles in between.

Here’s another way to look at it. Plotting all wells at the same origin and rotating by the wellbore orientation, we can get a better sense of the distribution (this is for one county only). Just like the histogram, this shows a large density of wells vertically oriented, and a couple smaller groups more horizontal, and a lot of scatter in between.

And finally we can come back to the map, adding color to the wells with orientation degrees. The red lines are from the World Stress Map, showing the local stress orientations.

Hopefully you now feel more comfortable calculating well orientation. Check back for future posts as we dig into additional applications!

Don’t forget to checkout the Spotfire template referenced in this post: https://exchange.ai/downloads/calculate-wellbore-orientation/

Nathan FesterHey Kyle,

Loved this tutorial. I am working with a slightly different dataset but trying to accomplish the same task – I have directional surveys which I’ve used the inclination and azimuth information to calculate average lateral azimuth. Can you elaborate on the radial plot that you created? What type of plot is this in Spotfire and how did you get the lines to represent the well orientation? Also, incorporating the world stress map is a really nice feature. Thanks for sharing.

Kyle LaMottaPost authorHi Nathan, happy to help, and glad to hear this is timely for you!

The radial plot is actually just a map chart, without the map layer. I added a marker layer, markered by well ID, and positioned all points at 0,0. Then changed the shape to a line, increased the size, and rotated by the orientation degrees.

Nathan FesterAmazing – thank you very much! Looking forward to more great content.