Sample Header Ad - 728x90

MySQL 8.0.18 - ST_Area returns invalid value

1 vote
1 answer
190 views
I have a problem with ST_Area function in MySQL 8.0.16. The result of the procedure call returns a different result than any library used to calculate the area of a polygon. Example: I have a GeoJSON with geometry like this:
{
        "type": "Polygon",
        "coordinates": [
            [
                [
                    16.91720977783202,
                    52.28469952907162
                ],
                [
                    16.910300407409657,
                    52.278608423688205
                ],
                [
                    16.919913444519032,
                    52.27753189128164
                ],
                [
                    16.91720977783202,
                    52.28469952907162
                ]
            ]
        ]
    }
The results of calulating area (in square meters) are: - Google Maps: 250165.80185391553 - Turf library: 250152.24833417358 - ST_Area(ST_GeomFromGeoJSON(@poly_json)): 202818.55768974536 First I was worried that GMaps (we got the coordinates from a map) is using some other projection, but it converts it into proper LatLng, so it shouldn't be a problem. Do you have an idea why the result is so different between calculating area on the database and on the client?
Asked by arkus (111 rep)
Feb 21, 2020, 02:16 PM
Last activity: Apr 20, 2023, 04:55 PM