1

I have an Openlayers application where I can input a centre point, width and height in meters from which I can generate a bounding box to display on the map. The problem I'm having is calculating the box with the correct length sides. The input data is as follows:

Latitude: 53.3530563113
Longitude: -6.45723718258
Height: 50 meters
Width: 50 meters

The lats and longs are converted to EPSG:900913 (3857) and the box creation maths performed to output the following coordinates, shown in both EPSG:900913 & EPSG:4326.

Centre Point X/Y: -718816.355096198/7048572.675410685

Bottom Left Point: 
 x: -718841.355096198, y: 7048547.675410685
 Long: -6.45746176140103, Lat: 53.35292226393439

Top Left Point:
 x: -718841.355096198, y: 7048597.675410685
 Long: -6.45746176140103, Lat: 53.35319035824405

Top Right Point:
 x: -718791.355096198, y: 7048597.675410685
 Long: -6.45701260375897, Lat: 53.35319035824405

Bottom Right Point:
 x: -718791.355096198, y: 7048547.675410685
 Long: -6.45701260375897, Lat: 53.35292226393439

The distance between any of the EPSG:900913 vertex points, or the length of any of the vertex is 50 meters (as set) but the distance between the Lat Long transforms is closer to 30 meters.

I'm aware of Cartesian and projected coordinate etc. systems but should the difference be this big or should I do my calculations some other way instead of transforming to 900913 and back to 4326, i.e. only in Lats and Longs to try and get the 50 meters correct in the 4326 system.

Any links/info or maths to get this right?

  • 1
    Welcome to GIS SE. As a new user, please take the Tour. Unfortunately, your problem is relying on a Mercator projection for distance calculation, instead of using an appropriate equidistant projection. Mercator is known to be very inaccurate for distance, infinitely so at the poles. – Vince Jul 4 '18 at 16:09
  • A very rough calculation for this type of distortion is to take the cos(latitude). At 53N, it's about 0.59--spot on! – mkennedy Jul 5 '18 at 0:19
  • So @Vince , instead of using a Web-Mercator projection like 900913, do the base maths in a equidistant projection relevant to the local coordinates and then convert to lats and longs? – Diplonics Jul 6 '18 at 10:28
  • Either that or use a geodetic function in degrees directly. It depends on what the server has available (and your comfort with writing servlets). – Vince Jul 6 '18 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.