# Finding N,S,E,W lat/lon at a determined radial distance from an input lat/long [duplicate]

I am working on a project where I geocode a users address to get a lat/lon value. With that value, is there a way to find the latitude and longitude of points that are a set distance (eg. 100m) away in a circle?

This diagram might help explain what I am looking for:

## marked as duplicate by whuber♦Mar 2 '18 at 18:56

• What software are you using? – JoshC Mar 1 '18 at 2:04
• @JoshC None for this. I am using Ruby for the project and just accessing the Google Maps API to geocode the string address input. – Matt Hough Mar 1 '18 at 5:17
• This Ruby module has the Direct method for a lat/long coord. github.com/kext/ruby-geographiclib – klewis Mar 1 '18 at 23:25

The formal name for your task is the Direct (aka Forward, aka First) Problem of Geodesy. The complication is that Earth is not spherical but spheroidal, making the task of locating a generic point at a bearing and distance from another point a partial differential equation (`dLon` changes with respect to `dLat`).

There are three basic approaches:

1. Ignore the spheroidal Earth, and solve the problem as a sphere (using the law of haversines)
2. Transform the frame of the problem to an appropriate projection, solve in Cartesian space, and de-project the result back to degrees (the solution provided by @Dan)
3. Solve the Direct problem using Vincenty's formulae

There is a fourth method: Use a code library to solve using any of the above methods.

When I was challenged, 25 years ago, to identify similar properties within 2 statue miles from a property for sale, I despaired of finding a effective solution, and decided to settle for using an iterative method of partially solving the problem, then measuring how far short I was, then trying again.

Then I tripped across the website of the US National Geodetic Survey, and discovered I only needed to port FORTRAN code to 'C'. Ironically, the partial differential equation is only solvable through iterative means, so I was chasing the right solution when a complete answer was dropped in my lap (albeit some assembly required).

You have a trivial case of my problem, since you only need to compute three points (east and west are at the same distance, in degrees longitude, from the center point), and the distances are so small that haversines will suffice, but given the number of times that this problem has been solved, tested, and published, I doubt you need to spend too much effort locating a code library that will meet your needs.

Note that I recently had a Python project that could have used a port of the code library I had wrapped around the port or NGS's code, but I actually used `arcpy.PointGeometry.pointFromAngleAndDistance()` since the client already had ArcGIS available. I haven't researched further, but I know PostGIS must have this solved, since ST_DWithin exists.

• Thanks for the great explanation. With the help of @klewis I did manage to find a Ruby gem that is a wrapper for GeographicLib that does exactly what I needed. Those formula's look intriguing and I will also have a look at them to gain a greater understanding of what exactly I am doing. – Matt Hough Mar 2 '18 at 1:30
• PostGIS has the Direct Geodesic Problem wrapped in ST_Project. This is an example I gave to a very similar question (actually, also asked by another Matt...) today. – ThingumaBob Mar 2 '18 at 18:52

If you need the distance to be an exact 100m then you will need to project your lat/long locations to a projected coordinate system. Then derive the north, south, east, west offset points by just adding the distance to the X and Y values as needed. Finally project all the points back to the original geographic coordinate system.

• Not true. There are geodetic APIs available to solve the so-called Direct problem without reprojection. – Vince Mar 1 '18 at 1:51
• My issue is that I don't really know how to do that kind of stuff. I have been trying to learn. But there seems to be a variety of different ways and disagreements (as can be seen from the comment above mine). – Matt Hough Mar 1 '18 at 5:18
• +1 because no need to bother with earth curvature for 100 m distance. – FelixIP Mar 1 '18 at 5:38
• @Vince, can you post a more detailed answer so that the OP can review and mark as correct? I fired off my answer before understanding fully Matt's development environment and I don't have any direct experience with the APIs mentioned. – Dan Mar 1 '18 at 21:03