[GIS] Calculate vertices’ coordinates of a rectangle, given midline and broadth of rectangle

coordinate systemcoordinatesextentsgeographyvertices

I have latitude and longitude of two points making the midline of a rectangle. Now I want to determine coordinates of 4 vertices of that rectangle. I know how to calculate on plane geometry by using line equation. But on geographic geometry, I'm new. I already read how to calculate one unit of latitude and longitude decimal degree but I'm still confused how to add them to a given point to calculate wanted points. My problem is like this:

Given:

  • Broadth of rectangle
  • Coordinates of two points making the midline, distance between these two points are equal to the width

Result: Coordinates of 4 vertices of rectangle

For example:
The given midline has two points:

A (10.767008,106.665884)
B (10.767715,106.667151)

Broadth is 4-metre long

All I could do now is to calculate the width of rectangle from those two points. How can I use width and height to calculate 4 vertices of this rectangle?

All of my calculated cases are on small scale (part of one street of a city) so I think altitude can be excluded

Best Answer

Being that you are dealing with such a small spatial area, we can get the four coordinate pairs using a couple of Euclidean equations. Unfortunately, GIS.SE doesn't support LaTeX equations, so I am going to assume you know basic geometry equations like slope, point-slope form, and the euclidean distance formula.

To better illustrate what is being done, refer to this image:

enter image description here

The goal is to find the coordinates of r, s, t, and u.

First, let's state the givens.

A (lat: 10.767008, lng: 106.665884) 
B (lat: 10.767715, lng: 106.667151)
r-s, t-u = 4 metres or roughly .000036036 decimal degrees at this latitude 

(if you need a more accurate way of determining this, there are plenty of posts on the subject)

Second, calculate the perpendicular slope of line A-B, we call it M.

Similar to slope equation, however with perpendicular slope your numerator is:

x_1 - x_2

And your denomimator is:

y_2 - y_1

This means:

M = (106.665884 - 106.667151)/(10.767715 - 10.767008)
M = -1.7920792

Third, we write out our equations for our segments, solving for the y coordinates:

y_r = M(x_r - 106.667151) + 10.767715
y_s = M(x_s - 106.667151) + 10.767715
y_t = M(x_t - 106.665884) + 10.767008
y_u = M(x_u - 106.665884) + 10.767008

Fourth, accounting for slope being positive or negative, we then write out the equations solving for the x coordinate of our unknown points. If the slope is negative, the x coordinate of s and u will be the result of the negative difference. If positive, the x coordinate of s and u will be the positive sum. Since our slope is negative, that means:

x_s = 106.667151 - (0.000018018 / sqrt(1 + (-1.7920792)^2))
x_s = 106.667139

x_r = 106.667151 + (0.000018018 / sqrt(1 + (-1.7920792)^2))
x_r = 106.667163

x_t = 106.665884 + (0.000018018 / sqrt(1 + (-1.7920792)^2))
x_t = 106.665896

x_u = 106.665884 - (0.000018018 / sqrt(1 + (-1.7920792)^2))
x_u = 106.665872

Fifth, now that we have our x coordinates, we can plug the values back into our segment equations and get our y coordinates.

y_r = -1.7920792 * (106.667163 - 106.667151) + 10.767715
y_r = 10.7676935

y_s = -1.7920792 * (106.667139 - 106.667151) + 10.767715
y_s = 10.7677365

y_t = -1.7920792 * (106.665896 - 106.665884) + 10.767008
y_t = 10.7669865

y_u = -1.7920792 * (106.665872 - 106.665884) + 10.767008
y_u = 10.7670295

So the coordinates to create your polygon would be:

r (lat: 10.7676935, lng: 106.667163)
s (lat: 10.7677365, lng: 106.667139)
t (lat: 10.7669865, lng: 106.665896)
u (lat: 10.7670295, lng: 106.665872)

Understand, they may be slightly off due to the assumption of metre to decimal degree length at this latitude, and values were rounded off.

Related Question