'How to get GPS coordinates of the centre of an rectangular area?

I have 4 GPS points that form the boundaries of a marine area. I need to know the GPS coordinates of the centre of this area, to use it as a basis for calculating the distance to other marine areas. To do this I was thinking of calculating the distances of the diagonals separating the GPS points of my area to obtain a centre point, but I am stuck on the method and the choice of the package to use to obtain the GPS coordinates of the centre of the area. Does anyone have an idea? Thanks in advance

(PS: I already tried to use marmap, but the study area is too small)

library(geosphere)

coor_zone <- c(3.15917,3.1725, 42.46783, 42.47033, 3.1745, 3.16033, 42.4655, 42.4625)
matrice_coord_zone <- matrix(coor_zone, nrow=2, ncol = 4)
colnames(matrice_coord_zone) <- c("long1", "lat1","long2", "lat2")
matrice_coord_zone <- data.frame(matrice_coord_zone)

matrice_coord_zone$distance <- distHaversine(matrice_coord_zone[,1:2], matrice_coord_zone[,3:4])

# result

    long1     lat1   long2    lat2 distance
1 3.15917 42.46783 3.17450 42.4655 1285.298
2 3.17250 42.47033 3.16033 42.4625 1326.077



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source