I have the function

--Ellipse(x,y,rx,ry,rotation,#of segments in 1/4 of ellipse)
SELECT ST_Translate( ST_Rotate( ST_Scale( ST_Buffer(ST_Point(0,0), 0.5, $6), $3, $4), $5), $1, $2)

I have points in WGS84 (x,y), radiuses in meters (rx, ry), rotation angle in degrees. And I need a new WGS84 geometry as a result.

As you can see I can't call this function without conversions between WGS84 and some metric SRID. But my points aren't in a definite region. So a SRID which is optimal for one point, throws an error for another point during conversion.

Is there a common way to get an optimal metric projection (SRID) for a WGS84 point? Or at least to use some rough, but world-wide universal metric projection? Or maybe there's a trick for this case?

  • I don't know if you ever found an answer but I had a similar question and was able to find what I needed. This might be of help to you. Possible Answer Here Commented Nov 30, 2016 at 20:20

2 Answers 2


There are several global projection based on WGS84. The most straightforward is the plate carrée (http://spatialreference.org/ref/epsg/wgs-84-plate-carree/) but it doesn't have nice geometric properties (you don't care if you just want to locate the points, but if you draw polygons this will have an impact.

Better choices could be, e.g., cylindrical equal area (the area of a polygon is preserved) or Mercator (which preserves angle and shapes of small objects). Both properties (area and shape) cannot be preserved on a projection, so you need to choose one property or select a "compromise" projection (e.g. Robinson).


One thing you can do is use PostGIS geography types which allow for metric geodesic calculations. Your code can be modified into the following:

--Ellipse(x,y,rx,ry,rotation,#of segments in 1/4 of ellipse)
SELECT ST_Translate( ST_Rotate( ST_Scale( ST_Buffer(ST_Point(0,0)::geography, 0.5, $6)::geometry, $3, $4), $5), $1, $2)

What you're doing is casting the point you create as a geography type with ::geography. Using the geography type in ST_Buffer allows you calculate the radius in meters geodesically. The result is then recast back into a geometry type with ::geometry so that the other functions can be applied. I realized you could do this after reading this question.

While this solves the problem with ST_Buffer, it doesn't not account for projection distortion. The main issue is that ST_Scale does not allow you to set a focal point for its scaling, which means this method will not work correctly.

Your Answer

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

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