I'm trying to create a bounding box from a simple Lat/Long, given an increase size in metres.

For example, create a bounding box from X/Y which goes outwards 5000m at the NE / SW corner. (yes, this isn't a circle so the radius isn't even, etc).


  • NorthEast corner Lat/Long
  • SouthWest corner Lat/Long.

My guess is I need to convert meters to something like Radians.

I'm used to just using SQL Server geospatial to create new polygons from a point. e.g. @somePoint.STBuffer(5000) creates a new circle with a radius of 5000 meters, from the centre point (given the point is WSG84).

How can I do this?

This is tools agnostic. As in, i'm just after some common math formula to calculate the new co-ordinates. I'm not using any GIS program, but doing some coding.

This will be used to search for all points in a poly, on Earth. I just need to create a rough/simple square from a Lat/Long (GPS coordinate). I will either do this in a spatial query in a DB (for example, RavenDb, SqlServer, PostGIS, etc) or more likely, in .NET C#. So I was hoping to see if there was a common algorithm before I checked if this has been coded up in some coding language.


1 Answer 1


Depending on the tolerance accepted in your work, you have several ways to solve your problem. Starting from the simplest and most imprecise to the most complex and precise.

But let's start with the first one, then you will see if the imprecision of the solution does not satisfy the work tolerance.

Let's think that the Earth is flat at 5000m around a point. If we want to draw a square, it would have 3535.53m on each side.

So it would suffice to find the meridian at that distance to the east and the parallel at that distance to the south, from the point of origin.

Now suppose that the Earth is a sphere of radius R.

If phi_1 is the latitude and lambda_1 is the longitude of the origin point, then the longitude of the destination point is:

lambda_2 = lambda_1 + R * cos(phi_1) * 2 * PI / 3535.53m

(where R * cos(phi_1) is the radius of the parallel of latitude phi_1).

And the latitude of the destination point is:

phi_2 = phi_1 - R * 2 * PI / 3535.53m

(not true near the South Pole).

That is all. The simplest and most imprecise way to get the longitude and latitude of the second point for the bounding box that you are trying to calculate.

The north side of the bounding box will measure 3535.53m meters over a sphere of radius R. The south side probably not. Both east and west sides will measure the same distance over the same sphere.

The shortest distance between the first and the second point will not measure exactly 5000m, because the Earth is not flat 5000m around a point, and the difference will depend of the radius R in the sphere and also of the location if you will compare it with an ellipsoid.

But it is simple, and an acceptable way to start thinking about geographic coordinates.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.