Fork me on GitHub

ST_MakeEllipse

Signature

POLYGON ST_MakeEllipse(POINT point, DOUBLE width, DOUBLE height);

Description

Constructs an elliptical POLYGON with the given width and height centered at the given point. Each ellipse contains 100 line segments.

Examples

SELECT ST_MakeEllipse('POINT(4 -5)', 2, 5);
-- Answer: POLYGON((5 -5, 4.998026728428272 -4.843023701176716, 4.9921147013144775 -4.686666916089239, 4.982287250728689 -4.531546713535689, 4.968583161128631 -4.378275282087863, 4.951056516295154 -4.227457514062632, 4.929776485888251 -4.079688618288305, 4.904827052466019 -3.9355517710873182, 4.8763066800438635 -3.7956158147457115, 4.844327925502015 -3.6604330125525086, 4.8090169943749475 -3.530536869268817, 4.770513242775789 -3.4064400256282754, 4.728968627421412 -3.2886322351782784, 4.684547105928688 -3.177578431446471, 4.637423989748689 -3.073716893060527, 4.587785252292473 -2.9774575140626314, 4.5358267949789965 -2.889180186244962, 4.481753674101715 -2.809233299890341, 4.425779291565073 -2.737932368834951, 4.3681245526846775 -2.6755587852793714, 4.3090169943749475 -2.6223587092621163, 4.248689887164855 -2.5785420971784223, 4.187381314585725 -2.5442818731782784, 4.125333233564304 -2.5197132467138053, 4.0627905195293135 -2.504933178929321, 4 -2.5, 3.9372094804706865 -2.504933178929321, 3.8746667664356957 -2.5197132467138057, 3.812618685414275 -2.5442818731782784, 3.751310112835145 -2.5785420971784223, 3.6909830056250525 -2.6223587092621163, 3.631875447315322 -2.6755587852793714, 3.574220708434927 -2.7379323688349513, 3.518246325898285 -2.8092332998903413, 3.464173205021003 -2.8891801862449626, 3.412214747707527 -2.9774575140626314, 3.3625760102513103 -3.073716893060527, 3.3154528940713113 -3.1775784314464715, 3.2710313725785882 -3.288632235178279, 3.2294867572242105 -3.4064400256282763, 3.1909830056250525 -3.5305368692688166, 3.1556720744979847 -3.6604330125525086, 3.1236933199561365 -3.795615814745712, 3.0951729475339804 -3.9355517710873187, 3.0702235141117487 -4.079688618288306, 3.0489434837048464 -4.227457514062632, 3.031416838871369 -4.378275282087863, 3.017712749271311 -4.531546713535689, 3.007885298685522 -4.68666691608924, 3.001973271571728 -4.843023701176717, 3 -5.000000000000001, 3.001973271571728 -5.156976298823284, 3.007885298685522 -5.313333083910761, 3.017712749271311 -5.468453286464312, 3.031416838871369 -5.621724717912137, 3.0489434837048464 -5.772542485937369, 3.0702235141117487 -5.920311381711696, 3.0951729475339804 -6.064448228912681, 3.1236933199561365 -6.2043841852542885, 3.155672074497985 -6.339566987447492, 3.1909830056250525 -6.469463130731183, 3.229486757224211 -6.5935599743717255, 3.2710313725785882 -6.711367764821722, 3.3154528940713113 -6.822421568553529, 3.3625760102513107 -6.926283106939474, 3.4122147477075266 -7.022542485937368, 3.4641732050210035 -7.110819813755038, 3.518246325898285 -7.190766700109659, 3.574220708434928 -7.262067631165049, 3.631875447315322 -7.324441214720629, 3.6909830056250525 -7.377641290737884, 3.7513101128351454 -7.421457902821578, 3.812618685414275 -7.455718126821722, 3.874666766435696 -7.480286753286195, 3.937209480470687 -7.4950668210706795, 4 -7.5, 4.0627905195293135 -7.4950668210706795, 4.125333233564304 -7.480286753286195, 4.187381314585725 -7.455718126821722, 4.248689887164855 -7.421457902821578, 4.3090169943749475 -7.377641290737884, 4.368124552684678 -7.324441214720628, 4.425779291565073 -7.262067631165049, 4.481753674101716 -7.190766700109658, 4.5358267949789965 -7.110819813755038, 4.587785252292473 -7.022542485937367, 4.63742398974869 -6.926283106939472, 4.684547105928688 -6.822421568553529, 4.728968627421412 -6.711367764821721, 4.770513242775789 -6.593559974371724, 4.8090169943749475 -6.469463130731182, 4.844327925502015 -6.3395669874474905, 4.8763066800438635 -6.2043841852542885, 4.90482705246602 -6.06444822891268, 4.929776485888252 -5.920311381711695, 4.951056516295154 -5.772542485937367, 4.968583161128631 -5.621724717912136, 4.982287250728689 -5.468453286464312, 4.9921147013144775 -5.313333083910759, 4.998026728428272 -5.156976298823283, 5 -5))

Comparison with ST_Buffer
SELECT ST_MakeEllipse('POINT(4 -5)', 4, 4),
       ST_Buffer('POINT(4 -5)', 2);
-- Answer:
--    POLYGON((6 -5, 5.996053456856544 -4.874418960941373, 5.984229402628956 -4.7493335328713915, 5.964574501457378 -4.62523737082855, 5.937166322257262 -4.502620225670291, 5.902113032590307 -4.381966011250105, 5.859552971776503 -4.263750894630644, 5.809654104932039 -4.148441416869854, 5.752613360087727 -4.03649265179657, 5.688655851004031 -3.928346410042007, 5.618033988749895 -3.8244294954150537, 5.541026485551578 -3.7251520205026205, 5.4579372548428235 -3.6309057881426225, 5.3690942118573775 -3.542062745157177, 5.2748479794973795 -3.4589735144484215, 5.175570504584946 -3.381966011250105, 5.071653589957993 -3.31134414899597, 4.96350734820343 -3.2473866399122726, 4.851558583130146 -3.190345895067961, 4.736249105369356 -3.1404470282234973, 4.618033988749895 -3.0978869674096927, 4.497379774329709 -3.062833677742738, 4.374762629171449 -3.0354254985426223, 4.2506664671286085 -3.015770597371044, 4.125581039058627 -3.003946543143457, 3.9999999999999996 -3, 3.874418960941373 -3.003946543143457, 3.7493335328713915 -3.0157705973710445, 3.6252373708285504 -3.035425498542623, 3.5026202256702903 -3.062833677742738, 3.381966011250105 -3.0978869674096927, 3.263750894630644 -3.1404470282234973, 3.1484414168698547 -3.190345895067961, 3.036492651796569 -3.247386639912273, 2.928346410042006 -3.3113441489959703, 2.824429495415054 -3.381966011250105, 2.7251520205026205 -3.4589735144484215, 2.6309057881426225 -3.5420627451571773, 2.5420627451571765 -3.630905788142623, 2.458973514448421 -3.725152020502621, 2.381966011250105 -3.8244294954150533, 2.31134414899597 -3.928346410042007, 2.247386639912273 -4.03649265179657, 2.190345895067961 -4.148441416869855, 2.1404470282234973 -4.263750894630644, 2.0978869674096927 -4.381966011250106, 2.062833677742738 -4.502620225670291, 2.0354254985426223 -4.625237370828551, 2.015770597371044 -4.7493335328713915, 2.003946543143457 -4.874418960941374, 2 -5.000000000000001, 2.003946543143457 -5.125581039058627, 2.015770597371044 -5.2506664671286085, 2.035425498542623 -5.37476262917145, 2.062833677742738 -5.49737977432971, 2.0978869674096927 -5.618033988749896, 2.1404470282234973 -5.736249105369357, 2.190345895067961 -5.851558583130146, 2.247386639912273 -5.96350734820343, 2.3113441489959703 -6.071653589957993, 2.3819660112501055 -6.175570504584947, 2.458973514448422 -6.27484797949738, 2.542062745157177 -6.3690942118573775, 2.6309057881426225 -6.4579372548428235, 2.725152020502621 -6.541026485551579, 2.8244294954150533 -6.618033988749895, 2.9283464100420074 -6.688655851004031, 3.0364926517965696 -6.752613360087727, 3.1484414168698556 -6.80965410493204, 3.263750894630644 -6.859552971776503, 3.381966011250105 -6.902113032590307, 3.502620225670291 -6.937166322257262, 3.625237370828551 -6.964574501457378, 3.7493335328713924 -6.984229402628956, 3.8744189609413735 -6.996053456856544, 3.9999999999999996 -7, 4.125581039058628 -6.996053456856544, 4.2506664671286085 -6.984229402628956, 4.3747626291714505 -6.964574501457378, 4.49737977432971 -6.937166322257262, 4.618033988749895 -6.902113032590307, 4.736249105369357 -6.859552971776503, 4.851558583130145 -6.809654104932039, 4.963507348203431 -6.752613360087727, 5.071653589957993 -6.68865585100403, 5.175570504584948 -6.618033988749894, 5.27484797949738 -6.541026485551578, 5.3690942118573775 -6.4579372548428235, 5.4579372548428235 -6.369094211857377, 5.541026485551579 -6.2748479794973795, 5.618033988749896 -6.175570504584945, 5.688655851004031 -6.071653589957993, 5.752613360087727 -5.96350734820343, 5.809654104932039 -5.851558583130144, 5.859552971776503 -5.736249105369356, 5.902113032590307 -5.618033988749893, 5.937166322257262 -5.497379774329709, 5.964574501457378 -5.37476262917145, 5.984229402628956 -5.250666467128608, 5.996053456856544 -5.125581039058627, 6 -5))
--    POLYGON((6 -5, 5.961570560806461 -5.390180644032257, 5.847759065022574 -5.765366864730179, 5.662939224605091 -6.111140466039204, 5.414213562373095 -6.414213562373095, 5.111140466039204 -6.662939224605091, 4.765366864730179 -6.847759065022574, 4.390180644032257 -6.961570560806461, 4 -7, 3.6098193559677436 -6.961570560806461, 3.2346331352698208 -6.847759065022574, 2.888859533960796 -6.662939224605091, 2.585786437626905 -6.414213562373095, 2.3370607753949093 -6.111140466039204, 2.152240934977426 -5.765366864730179, 2.038429439193539 -5.390180644032255, 2 -4.999999999999998, 2.0384294391935396 -4.609819355967741, 2.1522409349774274 -4.234633135269818, 2.337060775394911 -3.888859533960793, 2.5857864376269073 -3.5857864376269024, 2.8888595339607983 -3.3370607753949075, 3.2346331352698243 -3.152240934977425, 3.609819355967748 -3.0384294391935383, 4.000000000000005 -3, 4.390180644032262 -3.03842943919354, 4.765366864730185 -3.1522409349774287, 5.11114046603921 -3.337060775394913, 5.414213562373099 -3.5857864376269095, 5.662939224605094 -3.8888595339608014, 5.847759065022577 -4.234633135269828, 5.961570560806463 -4.609819355967751, 6 -5))

Note: This example shows that the only difference between a circle constructed using ST_MakeEllipse and a circle constructed using ST_Buffer is the number of line segments in the approximation. ST_MakeEllipse is more fine-grained (100 segments rather than 32).

See also